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 RGB bitcount 8 #7

Merged
merged 5 commits into from
Oct 30, 2023
Merged

Conversation

radarhere
Copy link

@radarhere radarhere commented Oct 25, 2023

  1. As requested, this allows for DDPF.RGB images with bitcount 8. I created a test image by copying mode-l.dds and manually changing the pfflags.

  2. While thinking about how to do that, I noticed that https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dds-pixelformat states that bitcount is

Valid when dwFlags includes DDPF_RGB, DDPF_LUMINANCE, or DDPF_YUV.

So I've added a commit to remove using the bitcount only based on DDPF.ALPHA. With my first change, we now support bitcount of 8 for RGB and LUMINANCE. I don't think we should pretend that bitcount of 8 doesn't need color transformation for YUV, so there shouldn't be any loss of functionality.

  1. The following code doesn't have any effect, because header is never used afterwards. So I've removed it.
if flags & DDSD.CAPS:
    header.seek(20, io.SEEK_CUR)
  1. I've added a test for two unimplemented bitcount errors. I copied uncompressed_l.dds and mode-rgb.dds and modified the bitcounts.

  2. I've added tests for BC1_UNORM and BC1_TYPELESS, by copying dxt1-rgb-4bbp-noalpha_MipMaps-1.dds and modifying it. However, I have removed BC1_UNORM_SRGB since that may be different.

Comment on lines -370 to -376
rawmode = rawmode[::-1]
elif pfflags & DDPF.ALPHA:
if bitcount == 8:
self._mode = "L"
else:
msg = f"Unsupported bitcount {bitcount} for {pfflags}"
raise OSError(msg)
Copy link
Owner

Choose a reason for hiding this comment

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

Why alpha block is gone?

Copy link
Author

Choose a reason for hiding this comment

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

The ALPHA block only supports a bitcount of 8. With the other changes here, we now support bitcount of 8 for RGB and LUMINANCE.

https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dds-pixelformat states that bitcount is

Valid when dwFlags includes DDPF_RGB, DDPF_LUMINANCE, or DDPF_YUV.

So only YUV is left - I don't think we should support YUV without actually transforming the color, so ALPHA can be removed.

@REDxEYE REDxEYE merged commit 4c635e4 into REDxEYE:improved_dds Oct 30, 2023
45 of 46 checks passed
@radarhere radarhere deleted the improved_dds branch October 30, 2023 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants