[2/3] gdiplus: If a 32-bit dib is selected in an hdc, use the dib directly.
Alexandre Julliard
julliard at winehq.org
Tue Dec 4 04:48:00 CST 2012
Vincent Povirk <madewokherd at gmail.com> writes:
> @@ -2264,6 +2266,41 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
> if(graphics == NULL)
> return InvalidParameter;
>
> + hbm = GetCurrentObject(hdc, OBJ_BITMAP);
> + if (hbm && GetObjectW(hbm, sizeof(dib), &dib) && dib.dsBm.bmBitsPixel == 32)
> + {
> + /* Make a bitmap object so we can use the alpha channel */
> + GpBitmap *bitmap;
> + DWORD height, stride;
> + BYTE *bits;
> +
> + height = abs(dib.dsBmih.biHeight);
> + stride = dib.dsBmih.biWidth * 4;
> +
> + if(dib.dsBmih.biHeight > 0) /* bottom-up */
> + {
> + bits = (BYTE*)dib.dsBm.bmBits + (height - 1) * stride;
> + stride = -dib.dsBmih.biWidth * 4;
> + }
> + else
> + bits = dib.dsBm.bmBits;
> +
> + retval = GdipCreateBitmapFromScan0(dib.dsBmih.biWidth, height, stride,
> + PixelFormat32bppPARGB, bits, &bitmap);
This won't work, you won't get a negative height with GetObject, and you
won't get DIB info at all for DDBs. Also not all DIBs are in PARGB format.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list