سؤال

I am successfully using the cool FreeImage library to load images in various formats.

Among these, gif and png with transparency information.

After loading the images, I convert them to 32bpp using FreeImage_ConvertToRawBits. With my png images, this works fine and I can retrieve all four Red/Green/Blue/Alpha components with meaningful Alpha values.

With gif images, on the opposite, the Alpha plane remains all 255's, even though FreeImage_IsTransparent says true.

What am I missing ? Is this related to the fact that gifs are palettized ? How do I handle this ?

هل كانت مفيدة؟

المحلول

I found a clear answer by looking at the source code: transparency is not handled when converting a palettized image to 32 bits. The Alpha field is always set to 255.

Anyway, it is quite possible to retrieve transparency from the original palettized bitmap, pixel by pixel, knowing the value of the transparent color (FreeImage_GetTransparentIndex(dib)).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top