appleseed icon indicating copy to clipboard operation
appleseed copied to clipboard

Wrong png output using Color4b when alpha channel not 2^8-1

Open ChinYing-Li opened this issue 4 years ago • 4 comments

螢幕截圖 2020-03-10 上午8 20 59 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))

ChinYing-Li avatar Mar 10 '20 12:03 ChinYing-Li

Is the problem in writing the files, or reading them? Can you provide a file written with alpha < 255?

dictoon avatar Mar 10 '20 12:03 dictoon

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) test_imagefilewriter_blue_full Here's Color4b (0, 0, 255, 128) test_imagefilewriter_blue_half

ChinYing-Li avatar Mar 10 '20 12:03 ChinYing-Li

Here's the details of test result: 螢幕截圖 2020-03-10 上午8 50 54 I think the problem is in reading.

ChinYing-Li avatar Mar 10 '20 12:03 ChinYing-Li

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.

dictoon avatar Mar 10 '20 13:03 dictoon