gdiplus: Avoid not necessary memory allocation for BITMAPINFO.
This commit is contained in:
parent
44e554b744
commit
bd601f9950
|
@ -4694,28 +4694,21 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
|
||||||
if (retval == Ok)
|
if (retval == Ok)
|
||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
BITMAPINFO *pbmi;
|
char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
|
||||||
|
BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
|
||||||
INT src_height;
|
INT src_height;
|
||||||
|
|
||||||
hdc = CreateCompatibleDC(NULL);
|
hdc = CreateCompatibleDC(NULL);
|
||||||
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
|
||||||
|
|
||||||
if (pbmi)
|
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
{
|
pbmi->bmiHeader.biBitCount = 0;
|
||||||
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
||||||
pbmi->bmiHeader.biBitCount = 0;
|
|
||||||
|
|
||||||
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;
|
pbmi->bmiHeader.biHeight = -src_height;
|
||||||
|
|
||||||
GetDIBits(hdc, hbm, 0, src_height, lockeddata.Scan0, pbmi, DIB_RGB_COLORS);
|
GetDIBits(hdc, hbm, 0, src_height, lockeddata.Scan0, pbmi, DIB_RGB_COLORS);
|
||||||
|
|
||||||
GdipFree(pbmi);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
retval = OutOfMemory;
|
|
||||||
|
|
||||||
DeleteDC(hdc);
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue