mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[GDI32]
- allocate sufficient buffer when creating a DIBSECTION compatible bitmap. Fixes bug 5822 svn path=/trunk/; revision=51014
This commit is contained in:
parent
1e2dd5d5d2
commit
fd5a3bdc63
1 changed files with 15 additions and 10 deletions
|
@ -348,8 +348,6 @@ CreateCompatibleBitmap(
|
||||||
INT Height)
|
INT Height)
|
||||||
{
|
{
|
||||||
PDC_ATTR pDc_Attr;
|
PDC_ATTR pDc_Attr;
|
||||||
HBITMAP hBmp = NULL;
|
|
||||||
DIBSECTION dibs;
|
|
||||||
|
|
||||||
if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))
|
if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -361,19 +359,26 @@ CreateCompatibleBitmap(
|
||||||
{
|
{
|
||||||
return NtGdiCreateCompatibleBitmap(hDC, Width, Height);
|
return NtGdiCreateCompatibleBitmap(hDC, Width, Height);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HBITMAP hBmp = NULL;
|
||||||
|
char buffer[sizeof(DIBSECTION) + 256*sizeof(RGBQUAD)];
|
||||||
|
DIBSECTION* pDIBs = (DIBSECTION*)buffer;
|
||||||
|
|
||||||
hBmp = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_BITMAP);
|
hBmp = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_BITMAP);
|
||||||
|
|
||||||
if ( GetObjectA(hBmp, sizeof(DIBSECTION), &dibs) != sizeof(DIBSECTION) )
|
if ( GetObjectA(hBmp, sizeof(DIBSECTION), pDIBs) != sizeof(DIBSECTION) )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ( dibs.dsBm.bmBitsPixel <= 8 )
|
if ( pDIBs->dsBm.bmBitsPixel <= 8 )
|
||||||
GetDIBColorTable(hDC, 0, 256, (RGBQUAD *)&dibs.dsBitfields);
|
GetDIBColorTable(hDC, 0, 256, (RGBQUAD *)&pDIBs->dsBitfields[0]);
|
||||||
|
|
||||||
dibs.dsBmih.biWidth = Width;
|
pDIBs->dsBmih.biWidth = Width;
|
||||||
dibs.dsBmih.biHeight = Height;
|
pDIBs->dsBmih.biHeight = Height;
|
||||||
|
|
||||||
return CreateDIBSection(hDC, (CONST BITMAPINFO *)&dibs.dsBmih, 0, NULL, NULL, 0);
|
return CreateDIBSection(hDC, (CONST BITMAPINFO *)&pDIBs->dsBmih, 0, NULL, NULL, 0);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue