[2/2] windowscodecs: BMP decoder should always return valid image resolution.

Dmitry Timoshkov dmitry at baikal.ru
Wed Jan 9 01:46:52 CST 2013


This patch should fix the regression reported in the bug 32687.
---
 dlls/windowscodecs/bmpdecode.c       | 29 +++++++++++++++++++++--------
 dlls/windowscodecs/tests/bmpformat.c |  2 --
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c
index e029369..d9e3a45 100644
--- a/dlls/windowscodecs/bmpdecode.c
+++ b/dlls/windowscodecs/bmpdecode.c
@@ -163,22 +163,35 @@ static HRESULT WINAPI BmpFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface
 
 static HRESULT BmpHeader_GetResolution(BITMAPV5HEADER *bih, double *pDpiX, double *pDpiY)
 {
+    LONG resx = 0, resy = 0;
+
     switch (bih->bV5Size)
     {
+    default:
     case sizeof(BITMAPCOREHEADER):
-        *pDpiX = 96.0;
-        *pDpiY = 96.0;
-        return S_OK;
+        break;
+
     case sizeof(BITMAPCOREHEADER2):
     case sizeof(BITMAPINFOHEADER):
     case sizeof(BITMAPV4HEADER):
     case sizeof(BITMAPV5HEADER):
-        *pDpiX = bih->bV5XPelsPerMeter * 0.0254;
-        *pDpiY = bih->bV5YPelsPerMeter * 0.0254;
-        return S_OK;
-    default:
-        return E_FAIL;
+        resx = bih->bV5XPelsPerMeter;
+        resy = bih->bV5YPelsPerMeter;
+        break;
+    }
+
+    if (!resx || !resy)
+    {
+        *pDpiX = 96.0;
+        *pDpiY = 96.0;
+    }
+    else
+    {
+        *pDpiX = resx * 0.0254;
+        *pDpiY = resy * 0.0254;
     }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI BmpFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
diff --git a/dlls/windowscodecs/tests/bmpformat.c b/dlls/windowscodecs/tests/bmpformat.c
index 5140577..48985b9 100644
--- a/dlls/windowscodecs/tests/bmpformat.c
+++ b/dlls/windowscodecs/tests/bmpformat.c
@@ -138,9 +138,7 @@ static void test_decode_24bpp(void)
 
                 hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
                 ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
-todo_wine
                 ok(dpiX == 96.0, "expected dpiX=96.0, got %f\n", dpiX);
-todo_wine
                 ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY);
 
                 hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult);
-- 
1.8.0.2




More information about the wine-patches mailing list