nickbabcock / Pfim

.NET Standard targa (.tga) and direct draw surface (.dds) image decoder
https://nickbabcock.github.io/Pfim/
MIT License
109 stars 18 forks source link

DDS: Add support for DXGI_FORMAT_B5G5R5A1_UNORM #84

Closed RunDevelopment closed 2 years ago

RunDevelopment commented 2 years ago

I have an image that uses the uncompressed DXGI_FORMAT_B5G5R5A1_UNORM format. Would it be possible to add support for DDS images of that format? The image in question.


When trying to open said image, Pfim throws (almost) the same error as it did in #82.

It seems like the improved error message is stored in the parameter name. image


Also, what is Pfim's approach to covering the DDS format? I saw that a bunch of other formats aren't supported either. Are there plans to one day support all of them?

nickbabcock commented 2 years ago

Thanks for the report, support will be added in #85 and the exception message should be updated 😅

Also, what is Pfim's approach to covering the DDS format? I saw that a bunch of other formats aren't supported either. Are there plans to one day support all of them?

Yeah those unsupported formats are mostly those in DXT10. As you can probably see, it's often not hard to add support, but I lack a corpus of images to test and the DDS images I run pfim on are not DXT10. The end result is that support is added as requested.

RunDevelopment commented 2 years ago

Thank you for fixing this so quickly!

I lack a corpus of images to test and the DDS images I run pfim on are not DXT10

Maybe I'm underestimating the problem, but couldn't we use textconv to convert a reference image into a bunch of DDS images with different pixel formats? If you want to, then I'll try to do that and send you images with the remaining DXGI formats.

nickbabcock commented 2 years ago

Maybe I'm underestimating the problem, but couldn't we use textconv to convert a reference image into a bunch of DDS images with different pixel formats? If you want to, then I'll try to do that and send you images with the remaining DXGI formats.

That would be a great start to add support for formats that have fallen through the cracks (ie: can be supported with minimal effort). You'll want to cross reference dxgi format list with what is unimplemented in Pfim and identify the dxgi formats that already fall into a Pfim ImageFormat:

https://github.com/nickbabcock/Pfim/blob/a69286bfcfea4abb6b03b2c8685b211cab427136/src/Pfim/ImageFormat.cs#L4-L25

Most of the dxgi formats, I suspect, will require some extra work. Optimistically formats like 128 bit images would only need an addition to ImageFormat. Philosophically, I'm be somewhat reluctant to add support for image formats that are unsupported by any example projects, as I like to do visual tests.

I believe there will be dxgi formats that require changes to the decoding, which are fine to be implemented in Pfim, but if there are dxgi formats that are deprecated or unused by industry then I think it is fine to omit that implementation.

RunDevelopment commented 2 years ago

In that case, I'll investigate the missing formats and open a new issue once I'm done.