Vincent Povirk : windowscodecs: Use alpha options in CreateBitmapFromHBITMAP.
Alexandre Julliard
julliard at winehq.org
Wed Nov 20 13:38:54 CST 2013
Module: wine
Branch: master
Commit: 8dafdd0a565385495be6c8d3c463d84d90a6f153
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8dafdd0a565385495be6c8d3c463d84d90a6f153
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Tue Nov 19 13:03:53 2013 -0600
windowscodecs: Use alpha options in CreateBitmapFromHBITMAP.
---
dlls/windowscodecs/imgfactory.c | 15 ++++++++++++++-
dlls/windowscodecs/tests/bitmap.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index bb4cf67..d31baa2 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -687,7 +687,20 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFact
format = GUID_WICPixelFormat24bppBGR;
break;
case 32:
- format = GUID_WICPixelFormat32bppBGR;
+ switch (option)
+ {
+ case WICBitmapUseAlpha:
+ format = GUID_WICPixelFormat32bppBGRA;
+ break;
+ case WICBitmapUsePremultipliedAlpha:
+ format = GUID_WICPixelFormat32bppPBGRA;
+ break;
+ case WICBitmapIgnoreAlpha:
+ format = GUID_WICPixelFormat32bppBGR;
+ break;
+ default:
+ return E_INVALIDARG;
+ }
break;
case 48:
format = GUID_WICPixelFormat48bppRGB;
diff --git a/dlls/windowscodecs/tests/bitmap.c b/dlls/windowscodecs/tests/bitmap.c
index 8de990a..14726f1 100644
--- a/dlls/windowscodecs/tests/bitmap.c
+++ b/dlls/windowscodecs/tests/bitmap.c
@@ -846,6 +846,41 @@ todo_wine
IWICBitmap_Release(bitmap);
DeleteObject(hbmp);
DeleteObject(hpal);
+
+ /* 32bpp alpha */
+ hbmp = create_dib(2, 2, 32, NULL, NULL);
+ hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, NULL, WICBitmapUseAlpha, &bitmap);
+ ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr);
+
+ hr = IWICBitmap_GetPixelFormat(bitmap, &format);
+ ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
+ ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGRA),
+ "unexpected pixel format %s\n", debugstr_guid(&format));
+
+ IWICBitmap_Release(bitmap);
+
+ /* 32bpp pre-multiplied alpha */
+ hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, NULL, WICBitmapUsePremultipliedAlpha, &bitmap);
+ ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr);
+
+ hr = IWICBitmap_GetPixelFormat(bitmap, &format);
+ ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
+ ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppPBGRA),
+ "unexpected pixel format %s\n", debugstr_guid(&format));
+
+ IWICBitmap_Release(bitmap);
+
+ /* 32bpp no alpha */
+ hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, NULL, WICBitmapIgnoreAlpha, &bitmap);
+ ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr);
+
+ hr = IWICBitmap_GetPixelFormat(bitmap, &format);
+ ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
+ ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGR),
+ "unexpected pixel format %s\n", debugstr_guid(&format));
+
+ IWICBitmap_Release(bitmap);
+ DeleteObject(hbmp);
}
static void test_clipper(void)
More information about the wine-cvs
mailing list