Skip to content

Support saving DDS images with pixel formats #8807

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

Merged
merged 6 commits into from
Mar 18, 2025
Merged

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Mar 8, 2025

Resolves #4864
Resolves #5499

With this, DXT1, DXT3, DXT5, BC2, BC3 and BC5 DDS images can be saved, with

im.save("out.dds", pixel_format="DXT1")

rather than saving uncompressed data. I've also added the loading of BC2 and BC3 images, since they were missing.

See https://learn.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-block-compression#bc1 for documentation (DXT1 is also known as BC1, DXT3 is also known as BC2 and DXT5 is also known as BC3).

For the BC2, BC3 and BC5 format, see https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide#dds-file-layout

If the DDS_PIXELFORMAT dwFlags is set to DDPF_FOURCC and dwFourCC is set to "DX10" an additional DDS_HEADER_DXT10 structure will be present

@radarhere radarhere changed the title Added DXT1 encoding Added DXT1 encoding when saving DDS images Mar 8, 2025
@radarhere radarhere force-pushed the dxt1 branch 3 times, most recently from a87b85f to 4e1b4e3 Compare March 13, 2025 12:53
@radarhere radarhere changed the title Added DXT1 encoding when saving DDS images Added DXT1 and DXT5 encoding when saving DDS images Mar 13, 2025
@radarhere radarhere changed the title Added DXT1 and DXT5 encoding when saving DDS images Added DXT1, BC3 and DXT5 encoding when saving DDS images Mar 14, 2025
@radarhere radarhere changed the title Added DXT1, BC3 and DXT5 encoding when saving DDS images Added DXT1, BC2, DXT3, BC3 and DXT5 encoding when saving DDS images Mar 15, 2025
@radarhere radarhere changed the title Added DXT1, BC2, DXT3, BC3 and DXT5 encoding when saving DDS images Support saving DDS images with pixel formats Mar 15, 2025
@hugovk hugovk merged commit 74fec91 into python-pillow:main Mar 18, 2025
70 checks passed
@radarhere radarhere deleted the dxt1 branch March 18, 2025 20:42
radarhere added a commit to radarhere/Pillow that referenced this pull request Mar 19, 2025
radarhere added a commit to radarhere/Pillow that referenced this pull request Mar 19, 2025
radarhere added a commit to radarhere/Pillow that referenced this pull request Mar 19, 2025
hugovk added a commit that referenced this pull request Mar 19, 2025
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.

Support BC5 DDS encoding Support DXT1, DXT3 and DXT5 DDS encoding
2 participants