PNG DataType alpha channel bug...

A forum for general AmigaOS 4.x support questions that are not platform-specific
User avatar
Futaura
Posts: 2
Joined: Fri Apr 24, 2015 4:06 pm
Location: UK
Contact:

Re: PNG DataType alpha channel bug...

Post by Futaura »

softwarefailure wrote:Well, ok, still, this behaviour doesn't really make that much sense to me because it's somewhat lacking consistency because then you can get either mskHasAlpha or mskHasTransparentColor for tRNS PNG images depending on the actual chunk layout. It's also not consistent with the behaviour concerning 32-bit ARGB PNG images. They could effectively also only use 256 colors with a monochrome transparency mask. Still, everybody would consider it a stupid idea to map this down to a mskHasTransparentColor image so 32-bit ARGBs are always returned as alpha channeled images and the datatype doesn't interpret/analyze the actual image and transparency data either. But with indexed images it seems to do it. To me, this is somewhat inconsistent.
Why expand an 8-bit image to 32-bit RGBA unnecessarily, when it is quick and easy to test for this... For an application, it should not need to know or be concerned about how the PNG tRNS chunk works. What happens if you read an 8-bit ILBM or GIF image that may set mskHasTransparentColor also? You need to handle mskHasTransparentColor generally, not just for PNG images, so it shouldn't matter what png.datatype is doing internally. Picture datatype subclasses are consistent in that they try to return the decoded image in as close to the original pixel format as possible. They do not expand (or indeed reduce) images unnecessarily - after all, picture.datatype is there to handle that for applications when they need it.

Also, legacy applications need to be considered - not just old OS3 apps, but OS4 apps not updated since the OS gained alpha support. When I originally added full RGBA output support to png.datatype, it did expand all 8-bit images with tRNS to RGBA, which I do recall did "break" several applications in that icons in their toolbars were no longer rendered correctly (no transparency, with purple backgrounds instead, etc). Hence, this behaviour was changed.
chris
Posts: 562
Joined: Sat Jun 18, 2011 11:05 am
Contact:

Re: PNG DataType alpha channel bug...

Post by chris »

broadblues wrote:The datatype does in fact return bmh_Masking == mskHasTransparentColor so the alpa data is not ignored. The software just needs to check for more than mskHasAlpha.

At least two of my projects also make this ommission and have now been corrected ...
Slightly confused here... surely if PDTA_PromoteMask is being used, then bmh_Masking should always be mskHasAlpha (or mskNone)?

If it's promoted to alpha, then mskHasTransparentColour is bogus information at that point.
User avatar
Futaura
Posts: 2
Joined: Fri Apr 24, 2015 4:06 pm
Location: UK
Contact:

Re: PNG DataType alpha channel bug...

Post by Futaura »

chris wrote:
broadblues wrote:The datatype does in fact return bmh_Masking == mskHasTransparentColor so the alpa data is not ignored. The software just needs to check for more than mskHasAlpha.

At least two of my projects also make this ommission and have now been corrected ...
Slightly confused here... surely if PDTA_PromoteMask is being used, then bmh_Masking should always be mskHasAlpha (or mskNone)?

If it's promoted to alpha, then mskHasTransparentColour is bogus information at that point.
Yes, the above quote is in the context of PDTA_PromoteMask not being used in the first place. In which case the application can choose to handle mskHasAlpha and mskHasTransparentColor internally. When using PDTA_PromoteMask, it doesn't affect png.datatype at all, but presumably picture.datatype does then change bmh_Masking to mskHasAlpha.
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Re: PNG DataType alpha channel bug...

Post by softwarefailure »

@Futaura: All right, the legacy argument is quite convincing... I guess I better adapt my code then :)
chris
Posts: 562
Joined: Sat Jun 18, 2011 11:05 am
Contact:

Re: PNG DataType alpha channel bug...

Post by chris »

Futaura wrote:Yes, the above quote is in the context of PDTA_PromoteMask not being used in the first place. In which case the application can choose to handle mskHasAlpha and mskHasTransparentColor internally. When using PDTA_PromoteMask, it doesn't affect png.datatype at all, but presumably picture.datatype does then change bmh_Masking to mskHasAlpha.
OK, that's what I thought should happen, thanks for clarifying.
Post Reply