Is it possible to load a picture from memory (byte[]
or stream
or Bitmap
) without saving it to disk?
This is the code I use to turn the byte[]
array into a Bitmap
:
unsafe { fixed (byte* ptr = Misc.ConvertFromUInt32Array(image)) { Bitmap bmp = new Bitmap(200, 64, 800, PixelFormat.Format32bppRgb, new IntPtr(ptr)); bmp.RotateFlip(RotateFlipType.Rotate180FlipX); bmp.MakeTransparent(Color.Black); bmp.Save("test.bmp"); } }
Instead of using Bmp.save()
, can I put the Bitmap
in the picture box on my form?
Right-click the folder, choose "Add existing item" and browse to your image (be sure the file filter is set to show image files). After adding the image, in the property sheet set the Copy to Output Directory to Copy if newer .
Have you tried this?
pictureBox.Image = bmp;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With