Ziqing Hui : windowscodecs: Implement DdsFrameDecode_GetPixelFormat().

Alexandre Julliard julliard at winehq.org
Wed Jul 1 15:22:47 CDT 2020


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

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Tue Jun 30 11:02:45 2020 +0800

windowscodecs: Implement DdsFrameDecode_GetPixelFormat().

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       | 15 +++++++++++++--
 dlls/windowscodecs/tests/ddsformat.c | 10 +++++-----
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/dlls/windowscodecs/ddsformat.c b/dlls/windowscodecs/ddsformat.c
index 7a27c48dee..43fb87dfb1 100644
--- a/dlls/windowscodecs/ddsformat.c
+++ b/dlls/windowscodecs/ddsformat.c
@@ -106,6 +106,7 @@ typedef struct dds_info {
     DXGI_FORMAT format;
     WICDdsDimension dimension;
     WICDdsAlphaMode alpha_mode;
+    const GUID *pixel_format;
 } dds_info;
 
 typedef struct dds_frame_info {
@@ -117,6 +118,7 @@ typedef struct dds_frame_info {
     UINT block_height;
     UINT width_in_blocks;
     UINT height_in_blocks;
+    const GUID *pixel_format;
 } dds_frame_info;
 
 typedef struct DdsDecoder {
@@ -229,6 +231,8 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h
         info->dimension = get_dimension(header, NULL);
         info->alpha_mode = get_alpha_mode_from_fourcc(header->ddspf.fourCC);
     }
+    info->pixel_format = (info->alpha_mode == WICDdsAlphaModePremultiplied) ?
+                         &GUID_WICPixelFormat32bppPBGRA : &GUID_WICPixelFormat32bppBGRA;
 
     /* get frame count */
     if (info->depth == 1) {
@@ -352,9 +356,15 @@ static HRESULT WINAPI DdsFrameDecode_GetSize(IWICBitmapFrameDecode *iface,
 static HRESULT WINAPI DdsFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface,
                                                     WICPixelFormatGUID *pPixelFormat)
 {
-    FIXME("(%p,%p): stub.\n", iface, pPixelFormat);
+    DdsFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
 
-    return E_NOTIMPL;
+    if (!pPixelFormat) return E_INVALIDARG;
+
+    *pPixelFormat = *This->info.pixel_format;
+
+    TRACE("(%p) -> %s\n", iface, debugstr_guid(pPixelFormat));
+
+    return S_OK;
 }
 
 static HRESULT WINAPI DdsFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
@@ -918,6 +928,7 @@ static HRESULT WINAPI DdsDecoder_Dds_GetFrame(IWICDdsDecoder *iface,
     frame_decode->info.block_height = DDS_BLOCK_HEIGHT;
     frame_decode->info.width_in_blocks = frame_width_in_blocks;
     frame_decode->info.height_in_blocks = frame_height_in_blocks;
+    frame_decode->info.pixel_format = This->info.pixel_format;
     frame_decode->data = HeapAlloc(GetProcessHeap(), 0, frame_size);
     hr = IStream_Seek(This->stream, seek, SEEK_SET, NULL);
     if (hr != S_OK) goto end;
diff --git a/dlls/windowscodecs/tests/ddsformat.c b/dlls/windowscodecs/tests/ddsformat.c
index 70f7e67e44..9bdf0bdb94 100644
--- a/dlls/windowscodecs/tests/ddsformat.c
+++ b/dlls/windowscodecs/tests/ddsformat.c
@@ -518,13 +518,13 @@ static void test_dds_decoder_frame_properties(IWICBitmapFrameDecode *frame_decod
     /* pixel format tests */
 
     hr = IWICBitmapFrameDecode_GetPixelFormat(frame_decode, NULL);
-    todo_wine ok(hr == E_INVALIDARG, "Test %u, frame %u: GetPixelFormat got unexpected hr %#x\n", i, frame_index, hr);
+    ok(hr == E_INVALIDARG, "Test %u, frame %u: GetPixelFormat got unexpected hr %#x\n", i, frame_index, hr);
     hr = IWICBitmapFrameDecode_GetPixelFormat(frame_decode, &pixel_format);
-    todo_wine ok(hr == S_OK, "Test %u, frame %u: GetPixelFormat failed, hr %#x\n", i, frame_index, hr);
+    ok(hr == S_OK, "Test %u, frame %u: GetPixelFormat failed, hr %#x\n", i, frame_index, hr);
     if (hr != S_OK) return;
-    todo_wine 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));
+    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));
 }
 
 static void test_dds_decoder_frame_data(IWICDdsFrameDecode *dds_frame, UINT frame_count, WICDdsParameters *params,




More information about the wine-cvs mailing list