Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Custom WebControl - Rendering Images

Custom WebControl - Rendering Images

Scheduled Pinned Locked Moved C#
htmlquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 643528
    wrote on last edited by
    #1

    I am building a custom WebControl and I would like to render an image in that custom control. I have a solution but it is not the solution I would like. Currently I am saving my image as a file and writing an html "img source" tag pointing to that file at the time I am asked to render my control into the HtmlTextWriter. The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Is this possible?? Thanks.

    K N 2 Replies Last reply
    0
    • U User 643528

      I am building a custom WebControl and I would like to render an image in that custom control. I have a solution but it is not the solution I would like. Currently I am saving my image as a file and writing an html "img source" tag pointing to that file at the time I am asked to render my control into the HtmlTextWriter. The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Is this possible?? Thanks.

      K Offline
      K Offline
      krisp
      wrote on last edited by
      #2

      What I had done is: set the "img source" to myPic.aspx then in myPic.aspx.cs in the Page_Load event, write to the output stream: "MIME=image/jpeg" // or something like that and then just write your image you draw to the stream as well. Bitmap bm; // draw to it bm.Save( Response ); // the response stream this works, i have done it before, but this is not exactly correct, can't remeber the exact words/code not sure of the correct form for MIME type, but look on google for MIME types or something. You can even pass parameters to yout myPic.aspx?lines=1,2,8,9 which could draw a line from 1,2 to 8,9 Or save the bmp in the Session and retreive it from the sesion when the client requests myPic.aspx, but i have not tried this session idea before. Hope that might help.

      1 Reply Last reply
      0
      • U User 643528

        I am building a custom WebControl and I would like to render an image in that custom control. I have a solution but it is not the solution I would like. Currently I am saving my image as a file and writing an html "img source" tag pointing to that file at the time I am asked to render my control into the HtmlTextWriter. The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Is this possible?? Thanks.

        N Offline
        N Offline
        Nick Parker
        wrote on last edited by
        #3

        Bob Scoverski wrote: The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Yes, I wrote an article on it here: Web Graphics On The Fly in ASP.NET[^]. Hope this helps. :) - Nick Parker
          My Blog

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups