gdiplus: Reimplement GdipCreateBitmapFromGdiDib by using GdipCreateBitmapFromHBITMAP.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
619ef41f33
commit
506f3bf53d
|
@ -1381,50 +1381,29 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO* info,
|
||||||
VOID *bits, GpBitmap **bitmap)
|
VOID *bits, GpBitmap **bitmap)
|
||||||
{
|
{
|
||||||
DWORD height, stride;
|
DWORD height, stride;
|
||||||
PixelFormat format;
|
HBITMAP hbm;
|
||||||
|
void *bmbits;
|
||||||
|
GpStatus status;
|
||||||
|
|
||||||
FIXME("(%p, %p, %p) - partially implemented\n", info, bits, bitmap);
|
TRACE("(%p, %p, %p)\n", info, bits, bitmap);
|
||||||
|
|
||||||
if (!info || !bits || !bitmap)
|
if (!info || !bits || !bitmap)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
hbm = CreateDIBSection(0, info, DIB_RGB_COLORS, &bmbits, NULL, 0);
|
||||||
|
if (!hbm)
|
||||||
|
return InvalidParameter;
|
||||||
|
|
||||||
height = abs(info->bmiHeader.biHeight);
|
height = abs(info->bmiHeader.biHeight);
|
||||||
stride = ((info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) >> 3) & ~3;
|
stride = ((info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) >> 3) & ~3;
|
||||||
|
TRACE("height %u, stride %u, image size %u\n", height, stride, height * stride);
|
||||||
|
|
||||||
if(info->bmiHeader.biHeight > 0) /* bottom-up */
|
memcpy(bmbits, bits, height * stride);
|
||||||
{
|
|
||||||
bits = (BYTE*)bits + (height - 1) * stride;
|
|
||||||
stride = -stride;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(info->bmiHeader.biBitCount) {
|
status = GdipCreateBitmapFromHBITMAP(hbm, NULL, bitmap);
|
||||||
case 1:
|
DeleteObject(hbm);
|
||||||
format = PixelFormat1bppIndexed;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
format = PixelFormat4bppIndexed;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
format = PixelFormat8bppIndexed;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
format = PixelFormat16bppRGB555;
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
format = PixelFormat24bppRGB;
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
format = PixelFormat32bppRGB;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
FIXME("don't know how to handle %d bpp\n", info->bmiHeader.biBitCount);
|
|
||||||
*bitmap = NULL;
|
|
||||||
return InvalidParameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GdipCreateBitmapFromScan0(info->bmiHeader.biWidth, height, stride, format,
|
|
||||||
bits, bitmap);
|
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: no icm */
|
/* FIXME: no icm */
|
||||||
|
|
Loading…
Reference in New Issue