gdiplus: Avoid not necessary memory allocation for BITMAPINFO.
This commit is contained in:
parent
8f87fc5b39
commit
35fc9c12dc
|
@ -1821,7 +1821,6 @@ static GpStatus get_screen_resolution(REAL *xres, REAL *yres)
|
|||
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
||||
PixelFormat format, BYTE* scan0, GpBitmap** bitmap)
|
||||
{
|
||||
BITMAPINFO* pbmi;
|
||||
HBITMAP hbitmap=NULL;
|
||||
INT row_size, dib_stride;
|
||||
BYTE *bits=NULL, *own_bits=NULL;
|
||||
|
@ -1851,9 +1850,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
|||
|
||||
if (format & PixelFormatGDI && !(format & (PixelFormatAlpha|PixelFormatIndexed)) && !scan0)
|
||||
{
|
||||
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
||||
if (!pbmi)
|
||||
return OutOfMemory;
|
||||
char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
|
||||
BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
|
||||
|
||||
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
pbmi->bmiHeader.biWidth = width;
|
||||
|
@ -1870,8 +1868,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
|||
|
||||
hbitmap = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
||||
|
||||
GdipFree(pbmi);
|
||||
|
||||
if (!hbitmap) return GenericError;
|
||||
|
||||
stride = dib_stride;
|
||||
|
|
Loading…
Reference in New Issue