gdiplus: Avoid not necessary memory allocation for BITMAPINFO.

This commit is contained in:
Dmitry Timoshkov 2013-01-15 12:48:56 +08:00 committed by Alexandre Julliard
parent 44e554b744
commit bd601f9950
1 changed files with 8 additions and 15 deletions

View File

@ -4694,14 +4694,12 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
if (retval == Ok)
{
HDC hdc;
BITMAPINFO *pbmi;
char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
INT src_height;
hdc = CreateCompatibleDC(NULL);
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
if (pbmi)
{
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biBitCount = 0;
@ -4712,11 +4710,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
GetDIBits(hdc, hbm, 0, src_height, lockeddata.Scan0, pbmi, DIB_RGB_COLORS);
GdipFree(pbmi);
}
else
retval = OutOfMemory;
DeleteDC(hdc);
GdipBitmapUnlockBits(*bitmap, &lockeddata);