System.Drawing.Image TO System.Web.UI.WebControls.Image RRS feed

  • Question

  • User-731604138 posted
    Is there a way to convert an System.Drawing.Image to an System.Web.UI.WebControls.Image? Im getting the image from an XML file, the binary being in base 64 string. I then convert it back to an array of bytes. My problem is that I can't find a way to create the System.Web.UI.WebControls.Image with a Stream or an array of bytes... I got the Image from Drawing but I can't convert it back to a WebControl Image. I suppose I must write down the file somewhere on the server then return the path but I dont want to leave these temporary images on the drive. Any ideas or suggestion anyone? Thanks Carl
    Tuesday, May 18, 2004 4:34 PM

All replies

  • User-599719271 posted
    that's not the way it works. you point the src of the webcontrols.image to an aspx script which then writes the drawing.image to the response stream. you can't just convert one into the other directly
    Wednesday, May 19, 2004 1:04 AM
  • User-731604138 posted
    Ok thanks, I will try that! Carl
    Wednesday, May 19, 2004 8:22 AM
  • User-731604138 posted
    Your solution worked ok Atrax, but I would like to know if you know another way to do this? I mean, suppose you have a byte[] with the file in it. What do you do with it to make it show? You want to use the .ImageUrl property because passing in parameter a base64 string will chop the string and you will get a "base64 char array" error. What im thinking at the moment is having the aspx page reparse the XML file given the ID in parameter then return it to the Response. You think there may be another solution than having to reparse the file? Thanks Carl
    Wednesday, May 19, 2004 2:23 PM
  • User-599719271 posted
    not really - if you're outputting HTML you need to have separate files for HTML and images (at present). if you were just outputting a PDF you might be able to do it this way, but presumably you're using HTML, meaning two separate files (or calls to the same file with different parameters).
    Wednesday, May 19, 2004 8:18 PM
  • User-1016270636 posted
    Can you provide vb.net example code? I want to take an webcontrols.Image and rotateflip it but I've got to get it into a system.drawing.image first...
    Tuesday, May 25, 2004 2:25 PM
  • User1796948403 posted
    FYI: you dont need to store it anywhere.. you can put all the graphic code on one aspx page, and in the end of that page, write on the page image.aspx... Bitmap image = ... //whatever Response.ContentType = "image/gif" ; image.Save ( Response.OutputStream , ImageFormat.Gif ) ; and on the page that you want to show the picture... good thing is you can still pass querystring parameters to image.aspx if needed.. bad thing is that the image gets created all the darn time. I dont know exactly what it does to your performance, but I know it doesnt do any good.
    Friday, July 30, 2004 2:03 AM
  • User1796948403 posted
    sorry.. didnt read all of atrax's comments.. same thing.
    Friday, July 30, 2004 2:05 AM