Bitmap을 byte[]로 변환하는 방법.

 

 


/*
 * ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <ggkids9211@gmail.com> wrote this file. As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return Hyunjun Kim.
 * ----------------------------------------------------------------------------
 */

byte[] ConvertBitmapToByteArray(Bitmap bitmap)
{
    byte[] result = null;
    if(bitmap != null)
    {
    	MemoryStream stream = new MemoryStream();
        bitmap.Save(stream, bitmap.RawFormat);
        result = stream.ToArray();
    }
    else
    {
    	Console.WriteLine("Bitmap is null.");
    }
    return result;
}

 

+ Recent posts