Ziqing Hui : windowscodecs: Correctly set pixel format of uncompressed DDS images.

Alexandre Julliard julliard at winehq.org
Fri Aug 28 15:17:58 CDT 2020


Module: wine
Branch: master
Commit: abd7454ecc394e63eee1944cd64685e7c582ae81
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=abd7454ecc394e63eee1944cd64685e7c582ae81

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Thu Aug 27 13:37:19 2020 +0800

windowscodecs: Correctly set pixel format of uncompressed DDS images.

Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Esme Povirk <esme at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/windowscodecs/ddsformat.c       | 10 ++++++----
 dlls/windowscodecs/tests/ddsformat.c |  6 +++---
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/dlls/windowscodecs/ddsformat.c b/dlls/windowscodecs/ddsformat.c
index 46e1074f25..2a9fc5c4bc 100644
--- a/dlls/windowscodecs/ddsformat.c
+++ b/dlls/windowscodecs/ddsformat.c
@@ -464,7 +464,6 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h
     if (header->depth) info->depth = header->depth;
     if (header->mipMapCount) info->mip_levels = header->mipMapCount;
 
-    format_info = get_dds_format(&header->ddspf);
     if (has_extended_header(header)) {
         if (header_dxt10->arraySize) info->array_size = header_dxt10->arraySize;
         info->format = header_dxt10->dxgiFormat;
@@ -472,20 +471,23 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h
         info->alpha_mode = header_dxt10->miscFlags2 & 0x00000008;
         info->data_offset = sizeof(DWORD) + sizeof(*header) + sizeof(*header_dxt10);
         if (is_compressed(info->format)) {
+            info->pixel_format = (info->alpha_mode == WICDdsAlphaModePremultiplied) ?
+                                 &GUID_WICPixelFormat32bppPBGRA : &GUID_WICPixelFormat32bppBGRA;
             info->pixel_format_bpp = 32;
         } else {
+            info->pixel_format = &GUID_WICPixelFormatUndefined;
             info->pixel_format_bpp = 0;
-            FIXME("Pixel format bpp is incorrect for uncompressed DDS image with extended header\n");
+            FIXME("Pixel format is incorrect for uncompressed DDS image with extended header\n");
         }
     } else {
+        format_info = get_dds_format(&header->ddspf);
         info->format = format_info->dxgi_format;
         info->dimension = get_dimension(header, NULL);
         info->alpha_mode = get_alpha_mode_from_fourcc(header->ddspf.fourCC);
         info->data_offset = sizeof(DWORD) + sizeof(*header);
+        info->pixel_format = format_info->wic_format;
         info->pixel_format_bpp = format_info->wic_format_bpp;
     }
-    info->pixel_format = (info->alpha_mode == WICDdsAlphaModePremultiplied) ?
-                         &GUID_WICPixelFormat32bppPBGRA : &GUID_WICPixelFormat32bppBGRA;
 
     if (header->ddspf.flags & (DDPF_RGB | DDPF_ALPHA | DDPF_LUMINANCE)) {
         info->bytes_per_block = header->ddspf.rgbBitCount / 8;
diff --git a/dlls/windowscodecs/tests/ddsformat.c b/dlls/windowscodecs/tests/ddsformat.c
index 139aaee7ed..b1beebf2fb 100644
--- a/dlls/windowscodecs/tests/ddsformat.c
+++ b/dlls/windowscodecs/tests/ddsformat.c
@@ -407,7 +407,7 @@ static struct test_data {
       { 1,  1,  1, 1, 1,   DXGI_FORMAT_B8G8R8X8_UNORM,     WICDdsTexture2D,   WICDdsAlphaModeUnknown },       TRUE },
     { test_dds_32bpp_argb, sizeof(test_dds_32bpp_argb),    WINCODEC_ERR_BADHEADER, 1,  4,  32,  &GUID_WICPixelFormat32bppBGRA,
       { 1,  1,  1, 1, 1,   DXGI_FORMAT_B8G8R8A8_UNORM,     WICDdsTexture2D,   WICDdsAlphaModeUnknown },       TRUE },
-    { test_dds_64bpp,      sizeof(test_dds_64bpp),         WINCODEC_ERR_BADHEADER, 1,  8,  64,  &GUID_WICPixelFormat64bppBGRA,
+    { test_dds_64bpp,      sizeof(test_dds_64bpp),         WINCODEC_ERR_BADHEADER, 1,  8,  64,  &GUID_WICPixelFormat64bppRGBA,
       { 1,  1,  1, 1, 1,   DXGI_FORMAT_R16G16B16A16_UNORM, WICDdsTexture2D,   WICDdsAlphaModeUnknown },       TRUE },
     { test_dds_96bpp,      sizeof(test_dds_96bpp),         WINCODEC_ERR_BADHEADER, 1,  12, 96,  &GUID_WICPixelFormat96bppRGBFloat,
       { 1,  1,  1, 1, 1,   DXGI_FORMAT_R32G32B32_FLOAT,    WICDdsTexture2D,   WICDdsAlphaModeUnknown },       TRUE },
@@ -941,8 +941,8 @@ static void test_dds_decoder_frame_properties(IWICBitmapFrameDecode *frame_decod
     hr = IWICBitmapFrameDecode_GetPixelFormat(frame_decode, &pixel_format);
     ok(hr == S_OK, "Test %u, frame %u: GetPixelFormat failed, hr %#x\n", i, frame_index, hr);
     if (hr != S_OK) return;
-    todo_wine_if(!IsEqualGUID(test_data[i].expected_pixel_format, &GUID_WICPixelFormat32bppBGRA) &&
-                 !IsEqualGUID(test_data[i].expected_pixel_format, &GUID_WICPixelFormat32bppPBGRA))
+    todo_wine_if(IsEqualGUID(test_data[i].expected_pixel_format, &GUID_WICPixelFormat24bppBGR) ||
+                 IsEqualGUID(test_data[i].expected_pixel_format, &GUID_WICPixelFormat96bppRGBFloat))
     ok(IsEqualGUID(&pixel_format, test_data[i].expected_pixel_format),
        "Test %u, frame %u: Expected pixel format %s, got %s\n",
        i, frame_index, debugstr_guid(test_data[i].expected_pixel_format), debugstr_guid(&pixel_format));




More information about the wine-cvs mailing list