G Guest May 24, 2005 #1 I have a Bitmap Object and I need to return it as array of bytes is it possible
M Mythran May 24, 2005 #2 Raed Sawalha said: I have a Bitmap Object and I need to return it as array of bytes is it possible Click to expand... private static byte[] GetBitmapBytes(Bitmap Bitmap) { MemoryStream memStream = new MemoryStream(); byte[] bytes; try { // Save the bitmap to the MemoryStream. Bitmap.Save(memStream, Bitmap.RawFormat); // Create the byte array. bytes = new byte[memStream.Length]; // Rewind. memStream.Seek(0, SeekOrigin.Begin); // Read the MemoryStream to get the bitmap's bytes. memStream.Read(bytes, 0, bytes.Length); // Return the byte array. return bytes; } finally { // Cleanup. memStream.Close(); } } HTH Mythran
Raed Sawalha said: I have a Bitmap Object and I need to return it as array of bytes is it possible Click to expand... private static byte[] GetBitmapBytes(Bitmap Bitmap) { MemoryStream memStream = new MemoryStream(); byte[] bytes; try { // Save the bitmap to the MemoryStream. Bitmap.Save(memStream, Bitmap.RawFormat); // Create the byte array. bytes = new byte[memStream.Length]; // Rewind. memStream.Seek(0, SeekOrigin.Begin); // Read the MemoryStream to get the bitmap's bytes. memStream.Read(bytes, 0, bytes.Length); // Return the byte array. return bytes; } finally { // Cleanup. memStream.Close(); } } HTH Mythran
C cody May 24, 2005 #3 You can use the Lock method on the bitmap. Raed Sawalha said: I have a Bitmap Object and I need to return it as array of bytes is it Click to expand... possible
You can use the Lock method on the bitmap. Raed Sawalha said: I have a Bitmap Object and I need to return it as array of bytes is it Click to expand... possible