Pillow
Pillow copied to clipboard
Support DXT1, DXT3 and DXT5 DDS encoding
Hi! Currently DDS is a read-only format: https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html?highlight=format#dds. This issue asks to add support for saving DDS images.
I've created #5402 to add RGB saving at least.
I've pushed another commit to the PR to add RGBA as well, resolving this issue - unless you have anything further to add.
Thanks a lot for your efforts. Which DDS formats does writing support? Ideally, it would be great to have all: DXT1, DXT3, and DXT5.
And thank you specially for RGBA, because it's what I've needed.
Ah, ok. At the moment, it only saves uncompressed data - so not DXT1, DXT3, DXT5 or DX10. That's a level more complex, and not something I'm going to attempt.
We can leave this issue open for those additional formats though if you want.
Let's leave it open.
Can someone point me the documentation to the DDS (DXTn) format/spec please? I could try to implement the DXT1 (and therefore DXT3 and 5) compression write support if possible…
A while ago, I attempted to implement DXT1 - https://github.com/radarhere/Pillow/tree/dds. Feel free to take that and build on it if you want.
I hit a wall when I realised that it was a lossy encoding, so I wasn't going to be a single perfect solution, and using someone else's logic would probably be better. https://github.com/nothings/stb/blob/master/stb_dxt.h seemed good, but I didn't return to this.
You asked for documentation though. Here are links that I found helpful
- https://docs.microsoft.com/en-us/windows/win32/direct3d9/opaque-and-1-bit-alpha-textures
- https://docs.microsoft.com/en-us/windows/win32/directshow/working-with-16-bit-rgb
- https://docs.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-block-compression#bc1