Commit abd7454e authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

windowscodecs: Correctly set pixel format of uncompressed DDS images.

parent e7abfd6f
......@@ -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;
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment