Hi,
My name is Ryan. I'm learning C# .Net using Visual Studio Express 2010, running on Windows 7. I would like to learn more on how to store an image to byte format within an array.
My question: Looking at the code reference below, how do I change (stream, System.Drawing.Imaging.ImageFormat.Png); to something that would have a direct reference to an image within a file? What are my alternative approaches?
Code sample:
public static byte[] ImageToByte2(Image img)
{
byte[] byteArray = new byte[0];
using (MemoryStream stream = new MemoryStream())
{
img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Close();
byteArray = stream.ToArray();
}
return byteArray;
}
|