Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ChinYing-Li opened this issue Mar 10, 2020 · 4 comments
Open

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

ChinYing-Li opened this issue Mar 10, 2020 · 4 comments

Comments

@ChinYing-Li
Copy link

螢幕截圖 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))

@dictoon
Copy link
Member

dictoon commented Mar 10, 2020

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

@ChinYing-Li
Copy link
Author

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
Copy link
Author

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

@dictoon
Copy link
Member

dictoon commented Mar 10, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants