Vincent Povirk : windowscodecs: Implement IWICBitmap:: SetResolution and GetResolution.

Alexandre Julliard julliard at winehq.org
Thu Aug 16 15:26:15 CDT 2012


Module: wine
Branch: master
Commit: 3e88d4ff0fcde40879228f129d430198f0d13f4b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3e88d4ff0fcde40879228f129d430198f0d13f4b

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Tue Aug 14 15:54:10 2012 -0500

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);




More information about the wine-cvs mailing list