appleseed
appleseed copied to clipboard
Wrong png output using Color4b when alpha channel not 2^8-1
I was writing experimental unit tests for png as suggested by @oktomus because Color4b(50, 100, 150, 42) does not work.
TEST_CASE(WritePNG_CorrectlyWritesImagePixels_blue_full)
const Color4b fill_color(0, 0, 255, 255);
TEST_CASE(WritePNG_CorrectlyWritesImagePixels_blue_half)
const Color4b fill_color(0, 0, 255, 128);
TEST_CASE(WritePNG_CorrectlyWritesImagePixels_red_full)
const Color4b fill_color(255, 0, 0, 255);
TEST_CASE(WritePNG_CorrectlyWritesImagePixels_red_half)
const Color4b fill_color(255, 0, 0, 128);
TEST_CASE(WritePNG_CorrectlyWritesImagePixels_green_full)
const Color4f fill_color(0, 255, 0, 255);
TEST_CASE(WritePNG_CorrectlyWritesImagePixels_green_halg)
const Color4f fill_color(0.0f, 1.0f, 0.0f, 1.0f);
TEST_CASE(WritePNG_CorrectlyWritesImagePixels_yellow_full)
const Color4b fill_color(255, 255, 0, 255);
As one can see, test cases where alpha channel not set to 255 failed. (I forgot to change the Color value of TEST_CASE(WritePNG_CorrectlyWritesImagePixels_green_halg)
)
Is the problem in writing the files, or reading them? Can you provide a file written with alpha < 255?
Is the problem in writing the files, or reading them? Can you provide a file written with alpha < 255?
Here's Color4b(0, 0, 255, 255) Here's Color4b (0, 0, 255, 128)
Here's the details of test result: I think the problem is in reading.
Thanks.
As far as I can tell, you've changed your PR to only write and read RGB channels in the PNG case so I can't check how you were reading back the image.
Could you investigate what happens when you read the image back, and why the alpha channel would be lost?
I'm pretty sure this is working correctly. A good way to double check would be to render one of the test scenes in sandbox/tests/test scenes/alpha/
, say scene #16, using a PNG version of leaf.exr
.