[2/5] windowscodecs: Implement IWICBitmap::GetPixelFormat.

Vincent Povirk madewokherd at gmail.com
Thu Aug 16 10:48:40 CDT 2012


-------------- next part --------------
From 0243a2736c8e3195fda2bceaf3c41cf281c46ca7 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Tue, 14 Aug 2012 15:39:58 -0500
Subject: [PATCH 2/7] windowscodecs: Implement IWICBitmap::GetPixelFormat.

---
 dlls/windowscodecs/bitmap.c       |   17 +++++++++++++----
 dlls/windowscodecs/tests/bitmap.c |   10 +++++-----
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/dlls/windowscodecs/bitmap.c b/dlls/windowscodecs/bitmap.c
index 0f93c76..0a7ecf5 100644
--- a/dlls/windowscodecs/bitmap.c
+++ b/dlls/windowscodecs/bitmap.c
@@ -43,6 +43,7 @@ typedef struct BitmapImpl {
     UINT width, height;
     UINT stride;
     UINT bpp;
+    WICPixelFormatGUID pixelformat;
 } BitmapImpl;
 
 typedef struct BitmapLockImpl {
@@ -195,9 +196,10 @@ static HRESULT WINAPI BitmapLockImpl_GetDataPointer(IWICBitmapLock *iface,
 static HRESULT WINAPI BitmapLockImpl_GetPixelFormat(IWICBitmapLock *iface,
     WICPixelFormatGUID *pPixelFormat)
 {
-    FIXME("(%p,%p)\n", iface, pPixelFormat);
+    BitmapLockImpl *This = impl_from_IWICBitmapLock(iface);
+    TRACE("(%p,%p)\n", iface, pPixelFormat);
 
-    return E_NOTIMPL;
+    return IWICBitmap_GetPixelFormat(&This->parent->IWICBitmap_iface, pPixelFormat);
 }
 
 static const IWICBitmapLockVtbl BitmapLockImpl_Vtbl = {
@@ -272,9 +274,15 @@ static HRESULT WINAPI BitmapImpl_GetSize(IWICBitmap *iface,
 static HRESULT WINAPI BitmapImpl_GetPixelFormat(IWICBitmap *iface,
     WICPixelFormatGUID *pPixelFormat)
 {
-    FIXME("(%p,%p)\n", iface, pPixelFormat);
+    BitmapImpl *This = impl_from_IWICBitmap(iface);
+    TRACE("(%p,%p)\n", iface, pPixelFormat);
 
-    return E_NOTIMPL;
+    if (!pPixelFormat)
+        return E_INVALIDARG;
+
+    memcpy(pPixelFormat, &This->pixelformat, sizeof(GUID));
+
+    return S_OK;
 }
 
 static HRESULT WINAPI BitmapImpl_GetResolution(IWICBitmap *iface,
@@ -446,6 +454,7 @@ HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
     This->height = uiHeight;
     This->stride = stride;
     This->bpp = bpp;
+    memcpy(&This->pixelformat, pixelFormat, sizeof(GUID));
 
     *ppIBitmap = &This->IWICBitmap_iface;
 
diff --git a/dlls/windowscodecs/tests/bitmap.c b/dlls/windowscodecs/tests/bitmap.c
index f772e0d..fc45375 100644
--- a/dlls/windowscodecs/tests/bitmap.c
+++ b/dlls/windowscodecs/tests/bitmap.c
@@ -152,8 +152,8 @@ static void test_createbitmap(void)
         base_lock_buffer = lock_buffer;
 
         hr = IWICBitmapLock_GetPixelFormat(lock, &pixelformat);
-        todo_wine ok(hr == S_OK, "IWICBitmapLock_GetPixelFormat failed hr=%x\n", hr);
-        todo_wine ok(IsEqualGUID(&pixelformat, &GUID_WICPixelFormat24bppBGR), "unexpected pixel format\n");
+        ok(hr == S_OK, "IWICBitmapLock_GetPixelFormat failed hr=%x\n", hr);
+        ok(IsEqualGUID(&pixelformat, &GUID_WICPixelFormat24bppBGR), "unexpected pixel format\n");
 
         hr = IWICBitmapLock_GetSize(lock, &width, &height);
         ok(hr == S_OK, "IWICBitmapLock_GetSize failed hr=%x\n", hr);
@@ -228,8 +228,8 @@ static void test_createbitmap(void)
         ok(lock_buffer == base_lock_buffer+6, "got %p, expected %p+6\n", lock_buffer, base_lock_buffer);
 
         hr = IWICBitmapLock_GetPixelFormat(lock, &pixelformat);
-        todo_wine ok(hr == S_OK, "IWICBitmapLock_GetPixelFormat failed hr=%x\n", hr);
-        todo_wine ok(IsEqualGUID(&pixelformat, &GUID_WICPixelFormat24bppBGR), "unexpected pixel format\n");
+        ok(hr == S_OK, "IWICBitmapLock_GetPixelFormat failed hr=%x\n", hr);
+        ok(IsEqualGUID(&pixelformat, &GUID_WICPixelFormat24bppBGR), "unexpected pixel format\n");
 
         hr = IWICBitmapLock_GetSize(lock, &width, &height);
         ok(hr == S_OK, "IWICBitmapLock_GetSize failed hr=%x\n", hr);
@@ -239,11 +239,11 @@ static void test_createbitmap(void)
         IWICBitmapLock_Release(lock);
     }
 
-todo_wine {
     hr = IWICBitmap_GetPixelFormat(bitmap, &pixelformat);
     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);
-- 
1.7.9.5


More information about the wine-patches mailing list