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

Fixed bug when reading BC5S DDS images #7401

Merged
merged 1 commit into from
Sep 20, 2023
Merged

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
52 checks passed
@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