converting byte[] to image file

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
 
G

Greg Young

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
 
R

Raghu Raman

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
 
D

Dr. Jochen Manns

What about this?


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top