Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
C# Bitmap <--> byte[] Converstion
SUBMITTED BY:
Guest
DATE:
July 5, 2013, 7:39 a.m.
FORMAT:
Text only
SIZE:
475 Bytes
Raw
Download
Tweet
HITS:
1001
Go to comments
Report
public static class BitmapConverter
{
public static Bitmap Bytes2Bitmap(this byte[] rawImage)
{
MemoryStream str = new MemoryStream(rawImage);
return Bitmap.FromStream(str, true) as Bitmap;
}
public static byte[] Bitmap2Bytes(this Bitmap bitmap)
{
return (byte[])TypeDescriptor.GetConverter(bitmap).ConvertTo(bitmap, typeof(byte[]));
}
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus