Here is the function to convert bitmap to byte[] in C# using ImageConverter class. ImageConverter class is present in System.Drawing.dll.
Here is the code to convert byte[] to bitmap in C#
public static Bitmap ByteArrayToBitMap(byte[] imageData)
{
Bitmap bmp;
using (var ms = new MemoryStream(imageData)){
bmp = new Bitmap(ms);}
}
public static byte[] BitmapToByteArray(Bitmap bitmap)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(bitmap, typeof(byte[]));
}
Here is the code to convert byte[] to bitmap in C#
public static Bitmap ByteArrayToBitMap(byte[] imageData)
{
Bitmap bmp;
using (var ms = new MemoryStream(imageData)){
bmp = new Bitmap(ms);}
return bmp;
Comments
Post a Comment