[4/5] windowscodecs: Implement IWICBitmap::SetResolution and GetResolution.

Vincent Povirk madewokherd at gmail.com
Thu Aug 16 10:50:06 CDT 2012


-------------- next part --------------
From 241e20632cbbcc68af817fc73b5482adb009e061 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Tue, 14 Aug 2012 15:54:10 -0500
Subject: [PATCH 4/7] windowscodecs: Implement IWICBitmap::SetResolution and
 GetResolution.

---
 dlls/windowscodecs/bitmap.c       |   30 ++++++++++++++++++++++++++----
 dlls/windowscodecs/tests/bitmap.c |    2 --
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/dlls/windowscodecs/bitmap.c b/dlls/windowscodecs/bitmap.c
index 22a4876..520fdef 100644
--- a/dlls/windowscodecs/bitmap.c
+++ b/dlls/windowscodecs/bitmap.c
@@ -44,6 +44,8 @@ typedef struct BitmapImpl {
     UINT stride;
     UINT bpp;
     WICPixelFormatGUID pixelformat;
+    double dpix, dpiy;
+    CRITICAL_SECTION cs;
 } BitmapImpl;
 
 typedef struct BitmapLockImpl {
@@ -256,6 +258,8 @@ static ULONG WINAPI BitmapImpl_Release(IWICBitmap *iface)
     if (ref == 0)
     {
         if (This->palette) IWICPalette_Release(This->palette);
+        This->cs.DebugInfo->Spare[0] = 0;
+        DeleteCriticalSection(&This->cs);
         HeapFree(GetProcessHeap(), 0, This->data);
         HeapFree(GetProcessHeap(), 0, This);
     }
@@ -295,9 +299,18 @@ static HRESULT WINAPI BitmapImpl_GetPixelFormat(IWICBitmap *iface,
 static HRESULT WINAPI BitmapImpl_GetResolution(IWICBitmap *iface,
     double *pDpiX, double *pDpiY)
 {
-    FIXME("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
+    BitmapImpl *This = impl_from_IWICBitmap(iface);
+    TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
+
+    if (!pDpiX || !pDpiY)
+        return E_INVALIDARG;
+
+    EnterCriticalSection(&This->cs);
+    *pDpiX = This->dpix;
+    *pDpiY = This->dpiy;
+    LeaveCriticalSection(&This->cs);
 
-    return E_NOTIMPL;
+    return S_OK;
 }
 
 static HRESULT WINAPI BitmapImpl_CopyPalette(IWICBitmap *iface,
@@ -408,9 +421,15 @@ static HRESULT WINAPI BitmapImpl_SetPalette(IWICBitmap *iface, IWICPalette *pIPa
 static HRESULT WINAPI BitmapImpl_SetResolution(IWICBitmap *iface,
     double dpiX, double dpiY)
 {
-    FIXME("(%p,%f,%f)\n", iface, dpiX, dpiY);
+    BitmapImpl *This = impl_from_IWICBitmap(iface);
+    TRACE("(%p,%f,%f)\n", iface, dpiX, dpiY);
 
-    return E_NOTIMPL;
+    EnterCriticalSection(&This->cs);
+    This->dpix = dpiX;
+    This->dpiy = dpiY;
+    LeaveCriticalSection(&This->cs);
+
+    return S_OK;
 }
 
 static const IWICBitmapVtbl BitmapImpl_Vtbl = {
@@ -462,6 +481,9 @@ HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
     This->stride = stride;
     This->bpp = bpp;
     memcpy(&This->pixelformat, pixelFormat, sizeof(GUID));
+    This->dpix = This->dpiy = 0.0;
+    InitializeCriticalSection(&This->cs);
+    This->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BitmapImpl.lock");
 
     *ppIBitmap = &This->IWICBitmap_iface;
 
diff --git a/dlls/windowscodecs/tests/bitmap.c b/dlls/windowscodecs/tests/bitmap.c
index a0926ab..34305cd 100644
--- a/dlls/windowscodecs/tests/bitmap.c
+++ b/dlls/windowscodecs/tests/bitmap.c
@@ -243,7 +243,6 @@ static void test_createbitmap(void)
     ok(hr == S_OK, "IWICBitmap_GetPixelFormat failed hr=%x\n", hr);
     ok(IsEqualGUID(&pixelformat, &GUID_WICPixelFormat24bppBGR), "unexpected pixel format\n");
 
-todo_wine {
     hr = IWICBitmap_GetResolution(bitmap, &dpix, &dpiy);
     ok(hr == S_OK, "IWICBitmap_GetResolution failed hr=%x\n", hr);
     ok(dpix == 0.0, "got %f, expected 0.0\n", dpix);
@@ -256,7 +255,6 @@ todo_wine {
     ok(hr == S_OK, "IWICBitmap_GetResolution failed hr=%x\n", hr);
     ok(dpix == 12.0, "got %f, expected 12.0\n", dpix);
     ok(dpiy == 34.0, "got %f, expected 34.0\n", dpiy);
-}
 
     hr = IWICBitmap_GetSize(bitmap, &width, &height);
     ok(hr == S_OK, "IWICBitmap_GetSize failed hr=%x\n", hr);
-- 
1.7.9.5


More information about the wine-patches mailing list