=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3dx9: Implement mapping from WICPixelFormat GUIDs to D3DFORMATs.
Alexandre Julliard
julliard at winehq.org
Mon May 7 14:29:27 CDT 2012
Module: wine
Branch: master
Commit: ec51783494972d5cab6402976448037a731422d1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ec51783494972d5cab6402976448037a731422d1
Author: Józef Kucia <joseph.kucia at gmail.com>
Date: Fri May 4 13:01:19 2012 +0200
d3dx9: Implement mapping from WICPixelFormat GUIDs to D3DFORMATs.
---
dlls/d3dx9_36/surface.c | 45 ++++++++++++++++++++++++++++++---------------
1 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index 30906d7..44d4e06 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -31,6 +31,34 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
/* Wine-specific WIC GUIDs */
DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22);
+static const struct
+{
+ const GUID *wic_guid;
+ D3DFORMAT d3dformat;
+} wic_pixel_formats[] = {
+ { &GUID_WICPixelFormat8bppIndexed, D3DFMT_L8 },
+ { &GUID_WICPixelFormat1bppIndexed, D3DFMT_L8 },
+ { &GUID_WICPixelFormat4bppIndexed, D3DFMT_L8 },
+ { &GUID_WICPixelFormat16bppBGR555, D3DFMT_X1R5G5B5 },
+ { &GUID_WICPixelFormat16bppBGR565, D3DFMT_R5G6B5 },
+ { &GUID_WICPixelFormat24bppBGR, D3DFMT_R8G8B8 },
+ { &GUID_WICPixelFormat32bppBGR, D3DFMT_X8R8G8B8 },
+ { &GUID_WICPixelFormat32bppBGRA, D3DFMT_A8R8G8B8 }
+};
+
+static D3DFORMAT wic_guid_to_d3dformat(const GUID *guid)
+{
+ int i;
+
+ for (i = 0; i < sizeof(wic_pixel_formats) / sizeof(wic_pixel_formats[0]); i++)
+ {
+ if (IsEqualGUID(wic_pixel_formats[i].wic_guid, guid))
+ return wic_pixel_formats[i].d3dformat;
+ }
+
+ return D3DFMT_UNKNOWN;
+}
+
/* dds_header.flags */
#define DDS_CAPS 0x1
#define DDS_HEIGHT 0x2
@@ -370,21 +398,8 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(LPCVOID data, UINT datasize, D3D
hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &pixel_format);
if (SUCCEEDED(hr)) {
- if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat1bppIndexed))
- info->Format = D3DFMT_L8;
- else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat4bppIndexed))
- info->Format = D3DFMT_L8;
- else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat8bppIndexed))
- info->Format = D3DFMT_L8;
- else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat16bppBGR555))
- info->Format = D3DFMT_X1R5G5B5;
- else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat24bppBGR))
- info->Format = D3DFMT_R8G8B8;
- else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat32bppBGR))
- info->Format = D3DFMT_X8R8G8B8;
- else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat32bppBGRA))
- info->Format = D3DFMT_A8R8G8B8;
- else {
+ info->Format = wic_guid_to_d3dformat(&pixel_format);
+ if (info->Format == D3DFMT_UNKNOWN) {
WARN("Unsupported pixel format %s\n", debugstr_guid(&pixel_format));
hr = D3DXERR_INVALIDDATA;
}
More information about the wine-cvs
mailing list