windowscodecs: Implement DdsFrameDecode_GetPixelFormat().

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Esme Povirk <esme@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2020-06-30 11:02:45 +08:00 committed by Alexandre Julliard
parent 359ee2ecc2
commit 82d90fc2a1
2 changed files with 18 additions and 7 deletions

View File

@ -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;

View File

@ -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,