gdiplus: Use one GetDIBits call instead of one per row.
This commit is contained in:
parent
04412f7a74
commit
431aa5bc3f
@ -4645,7 +4645,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
|||||||
GpStatus retval;
|
GpStatus retval;
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
BitmapData lockeddata;
|
BitmapData lockeddata;
|
||||||
INT y;
|
|
||||||
|
|
||||||
TRACE("%p %p %p\n", hbm, hpal, bitmap);
|
TRACE("%p %p %p\n", hbm, hpal, bitmap);
|
||||||
|
|
||||||
@ -4695,14 +4694,10 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
|||||||
if (retval == Ok)
|
if (retval == Ok)
|
||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
HBITMAP oldhbm;
|
|
||||||
BITMAPINFO *pbmi;
|
BITMAPINFO *pbmi;
|
||||||
INT src_height, dst_stride;
|
INT src_height;
|
||||||
BYTE *dst_bits;
|
|
||||||
|
|
||||||
hdc = CreateCompatibleDC(NULL);
|
hdc = CreateCompatibleDC(NULL);
|
||||||
oldhbm = SelectObject(hdc, hbm);
|
|
||||||
|
|
||||||
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
||||||
|
|
||||||
if (pbmi)
|
if (pbmi)
|
||||||
@ -4713,30 +4708,15 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
|||||||
GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
|
GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
|
||||||
|
|
||||||
src_height = abs(pbmi->bmiHeader.biHeight);
|
src_height = abs(pbmi->bmiHeader.biHeight);
|
||||||
|
pbmi->bmiHeader.biHeight = -src_height;
|
||||||
|
|
||||||
if (pbmi->bmiHeader.biHeight > 0)
|
GetDIBits(hdc, hbm, 0, src_height, lockeddata.Scan0, pbmi, DIB_RGB_COLORS);
|
||||||
{
|
|
||||||
dst_bits = (BYTE*)lockeddata.Scan0+lockeddata.Stride*(src_height-1);
|
|
||||||
dst_stride = -lockeddata.Stride;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dst_bits = lockeddata.Scan0;
|
|
||||||
dst_stride = lockeddata.Stride;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (y=0; y<src_height; y++)
|
|
||||||
{
|
|
||||||
GetDIBits(hdc, hbm, y, 1, dst_bits+dst_stride*y,
|
|
||||||
pbmi, DIB_RGB_COLORS);
|
|
||||||
}
|
|
||||||
|
|
||||||
GdipFree(pbmi);
|
GdipFree(pbmi);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
retval = OutOfMemory;
|
retval = OutOfMemory;
|
||||||
|
|
||||||
SelectObject(hdc, oldhbm);
|
|
||||||
DeleteDC(hdc);
|
DeleteDC(hdc);
|
||||||
|
|
||||||
GdipBitmapUnlockBits(*bitmap, &lockeddata);
|
GdipBitmapUnlockBits(*bitmap, &lockeddata);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user