Image Conversion in .NET
Reading binary data from an image
sample code:
string path = “C:\\img1.jpg”;
FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read);
byte[] b = new byte[fs.Length];
fs.Read(b, 0, b.Length);
fs.Close();
Converting the binary data from Bytes to String
sample code:
string str = Convert.ToBase64String(b);
Converting the String back to an Image
sample code:
MemoryStream ms = new MemoryStream();
Image img11;
byte[] b1;
b1 = Convert.FromBase64String(str);
ms = new System.IO.MemoryStream(b1);
img11 = System.Drawing.Image.FromStream(ms);
