I have an image (in .png format), and I want this picture to convert to binary.
How can this be done using C#?
First, convert the image into a byte array using ImageConverter class. Then specify the mime type of your png image, and voila!
Here's an example:
TypeConverter tc = TypeDescriptor.GetConverter(typeof(Byte[]));
Response.ContentType = "image/png";
Response.BinaryWrite((Byte[])tc.ConvertTo(img,tc));
Try this:
Byte[] result
= (Byte[])new ImageConverter().ConvertTo(yourImage, typeof(Byte[]));