Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #7386

In #5501, I added BC5 reading. When I did so, I added the following code to bring SNORM data into the UNORM range.

a0 = (b.a0 + 255) / 2;
a1 = (b.a1 + 255) / 2;

However, the resulting PNG in our test suite has artifacts - look at the lower middle and upper right of the image.

This was accepted at the time, but #7386 has raised the question again.

Thinking about it now, if the goal is to move from -128 - 127 to 0 to 255, then

a0 = b.a0 + 128;
a1 = b.a1 + 128;

seems like another answer - and indeed, it produces a result without artifacts.

@radarhere radarhere changed the title Corrected converting signed values to unsigned in BC5S Fixed bug when reading BC5S DDS images Sep 16, 2023
@radarhere radarhere merged commit 8d81fd9 into python-pillow:main Sep 20, 2023
@radarhere radarhere deleted the bc5s branch September 20, 2023 08:29
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

Successfully merging this pull request may close these issues.

DDS BC5_SNORM images are decoded incorrectly

2 participants