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

Added reading 8-bit color DDS images #7426

Merged
merged 3 commits into from Sep 30, 2023
Merged

Conversation

radarhere
Copy link
Member

Resolves #7423

The issue has found a DDS image that has the DDPF_PALETTEINDEXED8 pixel format

# Pixel Format
DDPF_ALPHAPIXELS = 0x1
DDPF_ALPHA = 0x2
DDPF_FOURCC = 0x4
DDPF_PALETTEINDEXED8 = 0x20

This pixel format is not mentioned at https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dds-pixelformat under "dwFlags", but is at https://learn.microsoft.com/en-us/previous-versions/ms783269(v=vs.85). It is an "8-bit color indexed" image.

Looking at the data in the issue, I guessed that the file structure was the header, followed by 1024 palette bytes, followed by the indexes to the palette. That produced a good result.

To create a test image, I took the header from hopper.dds, manually changed the width, height and pixel format flags, and put together code to write out the palette and indexes of transparent.gif.

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Worth adding to release notes or documenting elsewhere?

@radarhere
Copy link
Member Author

Sure, I've added it to the release notes and the file formats documentation.

@hugovk hugovk merged commit c2f7ea5 into python-pillow:main Sep 30, 2023
54 checks passed
@hugovk
Copy link
Member

hugovk commented Sep 30, 2023

Thanks!

@radarhere radarhere deleted the dds_palette branch October 1, 2023 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to open DDS image: Unimplemented pixel format
3 participants