25 May, 2009
2 Comments
0 categories
/// <summary> /// Covert a bitmap to a byte array /// </summary> /// <param name="bitmap"></param> /// <returns> /// byte array, when bitmap could be converted /// null, when bitmap is null /// null, when bitmap could not be converted to byte array /// </returns> public byte[] ConvertBitMapToByteArray(Bitmap bitmap) { byte[] result = null; if (bitmap != null) { MemoryStream stream = new MemoryStream(); bitmap.Save(stream, bitmap.RawFormat); result = stream.ToArray(); } return result; }
Tags: C#
I’ trying this but i have this exception when attempt to fill a private byte[] field with the return of this method, can you help me?
System.StackOverflowException
A first chance exception of type ‘System.ArgumentNullException’ occurred in System.Drawing.dll