I'm still learning Emgu CV and I need to load Image from byte array which contains a PNG32 data. I'm loading image as follows (this is working example):
FileStream fs;
Bitmap bitmap;
Image<Rgba, byte> image;
bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
image = new Image<Rgba, byte>(width, height)
{
Bytes = data // data is my byte array
};
if(File.Exists("1.png"))
File.Delete("1.png");
image.Save("1.png");
fs = new FileStream("1.png", FileMode.Open);
bitmap = (Bitmap)Image.FromStream(fs); // this is image what I need
fs.Close();
File.Delete("1.png");
because, if I will use just
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
Image<Rgba, byte> image = new Image<Rgba, byte>(width, height)
{
Bytes = data // data is my byte array
};
bitmap = image.Bitmap; // this is image what I need
the background of my bitmap will be white, however my initial image has a transparent background.
So, I think that there is more optimal way to load Image from binary data than in my first example, but I don't know it. Can anyone help?