Commit 8dafdd0a authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

windowscodecs: Use alpha options in CreateBitmapFromHBITMAP.

parent 48ae4314
......@@ -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;
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment