google / wuffs

Wrangling Untrusted File Formats Safely
Other
4.06k stars 129 forks source link

How to get the correct 'transparency' value in the DecodeImage API? #147

Closed ghost closed 1 month ago

ghost commented 1 month ago

Hello, I need get the correct 'transparency' value when using DecodeImage, correct means the source format does has alpha channel, but now for BMP files I always get PIXEL_FORMAT__BGRA_NONPREMUL even for 24bpp non-alpha files.

My example code can be found here: https://github.com/iyzsong/onscripter-libretro/blob/main/sdl-libretro/SDL_image.cpp

In SelectPixfmt, I use ic.pixcfg.pixel_format().transparency(), which comment as "the image file's natural pixel format", does this pixel_format mean to have the correct transparency value or is there another way to get what I want?

Thanks.

nigeltao commented 1 month ago

Thanks for the bug report. Let me know if release/c/wuffs-unsupported-snapshot.c doesn't fix it for you.

ghost commented 1 month ago

It works now, thank you!