converting byte[] to image file

  • Thread starter Thread starter Raghu Raman
  • Start date Start date
R

Raghu Raman

Hi

i want to save the read the image file and show it on a image control of
a mobile webform .But the mobile control does not support html images
,so i am forced to use the server image control to show the read image.

i have the image available in a datarow which is read from db. As
control only has the imageurl property ,i need to save the read image to
an image image file and then assign it to the control .



Please tell me
how can i convert the byte[] form of a image to an image file so that
i can assign it to the image control

Thanks
Raghu

Six faces rule the world
 
Just save the byte [] as a temp file and generate the appropriate filename
.... or you could use another page that returns the byte [] directly to
response with a content type appropriate for an image then use a link that
pointed to this page with an appropriate id set in the querystring.

Cheers,

Greg
 
Greg

Thx that works

FileStream fs=new FileStream(@"c:\abc.jpeg",
FileMode.OpenOrCreate,FileAccess.ReadWrite);
BinaryWriter w= new BinaryWriter(fs);
w.Write((byte[])dr["Image"]);
w.Close();

Regds
Raghu
Six faces rule the world
 
What about this?


using (MemoryStream stream = new MemoryStream((byte[])dr["Image"], false))
pictureBox1.Image = Image.FromStream(stream);
 
Back
Top