Click here to Skip to main content
15,917,456 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello Friend's
I have database in binary form in picture.
i have one form and one class
in class have sqlconnection and form have not
i want to pass using like this to second form : public byte[] imege { get; set; }
plz tell me how to i do this?
Posted
Comments
Sergey Alexandrovich Kryukov 30-Nov-11 2:02am    
Tag it: WPF or System.Drawing (can be used with Forms)?
--SA
kuldeepkumartak 30-Nov-11 2:04am    
yes we are use with form system.drawing

Do you have Byte[] (byteArray) ?

Write the byte to file directly

C#
System.IO.File.WriteAllBytes("C:\Text.jpg");  //Replace your Filepath
 
Share this answer
 
v3
If you convert a byte to an image, it will be really small image. :-)

You really are asking about an array of bytes. Here is the way: you put the bytes in a memory stream and read this memory stream with System.Drawing.Image.FromStream.

C#
byte[] imageData = //...;

//...

using (System.IO.MemoryStream stream = new System.IO.MemoryStream(imageData)) {
    System.Drawing.Image image = new System.Drawing.Image.FromStream(stream);
} // stream dispose is called here implicitly 


See:
http://msdn.microsoft.com/en-us/library/system.drawing.image.fromstream.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.memorystream.aspx[^].

If you want, WPF has similar methods. Please see, for example: http://forums.silverlight.net/p/44637/121951.aspx[^].

—SA
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900