• Advertisement
Sign in to follow this  

GDI Bitmap from .bmp file transparency lost

This topic is 2198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know most think bmp's dont support alpha but it does, I cant use png thats far too slow so I need a way of making a Bitmap object from a bmp with alpha in a byte[]/MemoryStream and I'm currently using this:
[color=black]var [color=yellow]gch = [color=#2b91af]GCHandle.[color=yellow]Alloc(>>>heres the bmp in a byte[]<<<, [color=#2b91af]GCHandleType.[color=yellow]Pinned);
[color=black]var [color=yellow]bmp = [color=black]new [color=#2b91af]Bitmap([color=yellow]_res.[color=yellow]Width, [color=yellow]_res.[color=yellow]Height, 4 * [color=yellow]_res.[color=yellow]Width, [color=#2b91af]PixelFormat.[color=yellow]Format32bppArgb, ([color=#2b91af]IntPtr)(([color=black]int)([color=yellow]gch.[color=yellow]AddrOfPinnedObject()) + 54));
the RotateFlip is required because the image comes out inverted but it sometimes throws an AccessViolationException which is an exception in unmanaged code that I cant catch but an InvalidOperationException is caught when I step it.

So is there an alternative or a simple fix for my existing code?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement