OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

Misread 4 channel PNG File

Open blendersfun opened this issue 15 years ago • 2 comments

This PNG file: http://azureabstraction.com/upload/files/aaron/linked_to_from_permenant_places/stuck_up_european_input.png

Does not read in properly with this test code: http://azureabstraction.com/upload/files/aaron/linked_to_from_permenant_places/matte.cpp.txt

Using the 0.11 version of the OIIO library.

When I run the simple cpp program, I get this output: Channels names: RGBA Format: uint8 Quantization: 0 255 0 255 Resolution, channels: 666 890, 4 First 4 channels: 0 0 0 255

(I expect the first four channels to not indicate a black pixel).

And the output image is this: http://azureabstraction.com/upload/files/aaron/linked_to_from_permenant_places/stuck_up_european_output.png

When I open the input image in Paintbrush and save it out again (as stuck_up_european_input2.png for example), it is read in and written out as I expect. (So this is a workaround for my project). But it does seem that whatever is different about this particular PNG file, it should be process properly by this simple program (as it opens in viewers properly).

As I am fairly new to graphics, I cannot diagnose what is special about this PNG further.

blendersfun avatar Sep 05 '11 01:09 blendersfun

The main problem here is that OIIO has a bug interpreting PNG files which simultaneously contain a gamma specification and an alpha channel. In particular, the associateAlpha function is seriously buggy. I'd post a fix, but the semantics of png's "gamma" is tripping me up so I'm holding off for now.

c42f avatar Sep 05 '11 04:09 c42f

I just pushed a fix for this to the master branch, it should now behave as expected.

c42f avatar Sep 16 '11 22:09 c42f