Jump to content
  • Advertisement
Sign in to follow this  
David Lake

GDI Bitmap from .bmp file transparency lost

This topic is 2377 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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!