windowscodecs: Introduce get_pixel_format_bpp().

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-08-17 10:23:14 +08:00 committed by Alexandre Julliard
parent c5675ec615
commit bec58b5e9c
1 changed files with 23 additions and 0 deletions

View File

@ -131,6 +131,7 @@ typedef struct dds_frame_info {
UINT width_in_blocks;
UINT height_in_blocks;
const GUID *pixel_format;
UINT pixel_format_bpp;
} dds_frame_info;
typedef struct DdsDecoder {
@ -446,6 +447,27 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h
if (info->dimension == WICDdsTextureCube) info->frame_count *= 6;
}
static UINT get_pixel_format_bpp(const GUID *pixel_format)
{
HRESULT hr;
UINT bpp = 0;
IWICComponentInfo *info = NULL;
IWICPixelFormatInfo* format_info = NULL;
hr = CreateComponentInfo(pixel_format, &info);
if (hr != S_OK) goto end;
hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void **)&format_info);
if (hr != S_OK) goto end;
IWICPixelFormatInfo_GetBitsPerPixel(format_info, &bpp);
end:
if (format_info) IWICPixelFormatInfo_Release(format_info);
if (info) IWICComponentInfo_Release(info);
return bpp;
}
static inline DdsDecoder *impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
{
return CONTAINING_RECORD(iface, DdsDecoder, IWICBitmapDecoder_iface);
@ -1090,6 +1112,7 @@ static HRESULT WINAPI DdsDecoder_Dds_GetFrame(IWICDdsDecoder *iface,
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->info.pixel_format_bpp = get_pixel_format_bpp(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;