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

Support for working with unexpanded P8/A8P8 images #520

Open
walbourn opened this issue Sep 26, 2024 · 1 comment
Open

Support for working with unexpanded P8/A8P8 images #520

walbourn opened this issue Sep 26, 2024 · 1 comment
Labels

Comments

@walbourn
Copy link
Member

walbourn commented Sep 26, 2024

Currently the DDS, TGA, and WIC readers always expand P8 and A8P8 format images to RGBA32. This is the primary workflow, and makes sense as the default behavior. Most of the operations/functions in the library do not support paletted data by design. Direct3D 11 and Direct3D 12 do not support palette texture formats, although in theory you could implement them with a programmable shader.

I could make use of the DXGI enumerations DXGI_FORMAT_P8 and DXGI_FORMAT_A8P8 which were added for video support to return the data in the original paletted form.

This would also require some way to retrieve the palette data as well (like adding a palette member to Image).

Requesting this behavior on read rather than the current behavior to always expand the data would require some specific behavior flag (DDS_FLAGS_ALLOW_P8, TGA_FLAGS_ALLOW_P8, WIC_FLAGS_ALLOW_P8).

Writing would be indicated by giving an input image with DXGI_FORMAT_P8 or DXGI_FORMAT_A8P8.

If there was some reason to support this palette workflow, then it would be worth considering adding a codec for the PCX which is a classic paletted format.

"palette workflow" would also imply the need for explicit functions to convert P8/A8P8 to RGBA32, and a function for converting RGBA32 to a P8/A8P8 image using something like "median cut" (see this article).

@walbourn walbourn changed the title Image loader support for unexpanded paletted images Image loader support for unexpanded P8/A8P8 images Sep 26, 2024
@walbourn walbourn changed the title Image loader support for unexpanded P8/A8P8 images Support for working with unexpanded P8/A8P8 images Sep 26, 2024
@karurung
Copy link

karurung commented Oct 5, 2024

Trying to create new flag constants such as 'DDS_FLAGS_ALLOW_P8', 'TGA_FLAGS_ALLOW_P8', and 'WIC_FLAGS_ALLOW_P8'. These flags should be clearly defined in your library to indicate that the reder should allow for paletted formats.

Also, considering the addition of a codec for classic paletted formats like PCX seems like a great step as well. PCX would be suport various image formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants