Author: tkreuzer
Date: Thu Jul 25 21:03:14 2013
New Revision: 59586
URL:
http://svn.reactos.org/svn/reactos?rev=59586&view=rev
Log:
[GDI32] Handle CBM_CREATDIB
[WIN32K] Make sure compressed DIBs have a bitmap size in the BITMAPINFOHEADER
Modified:
branches/dib_rewrite/win32ss/gdi/gdi32/objects/dibitmap.c
branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c
Modified: branches/dib_rewrite/win32ss/gdi/gdi32/objects/dibitmap.c
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/gdi32/o…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/gdi32/objects/dibitmap.c [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/gdi32/objects/dibitmap.c [iso-8859-1] Thu Jul 25
21:03:14 2013
@@ -198,6 +198,11 @@
if (pbmi->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
{
pbmi = ConvertBitmapCoreInfo(pbmi, iUsage);
+ if (pbmi == NULL)
+ {
+ return NULL;
+ }
+
bConvertedInfo = TRUE;
}
@@ -227,21 +232,30 @@
cjInfo = 0;
}
+ /* Check for the undocumented CBM_CREATDIB flag */
if (fdwInit & CBM_CREATDIB)
{
- if (!pbmi) return NULL;
-
- //__debugbreak();
- return 0;
- }
- else
- {
- if (!pbmih)
+ /* We need a BITMAPINFO */
+ if (pbmi == NULL)
+ {
+ /* LastError is not set here! */
+ goto cleanup;
+ }
+
+ /* Get the dimension from the BITMAPINFO */
+ cx = pbmi->bmiHeader.biWidth;
+ cy = abs(pbmi->bmiHeader.biHeight);
+ }
+ else
+ {
+ /* We need the BITMAPINFOHEADER */
+ if (pbmih == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
goto cleanup;
}
+ /* Check the type of the BITMAPINFOHEADER */
if (pbmih->biSize == sizeof(BITMAPCOREHEADER))
{
PBITMAPCOREHEADER pbch = (PBITMAPCOREHEADER)pbmih;
@@ -258,11 +272,13 @@
SetLastError(ERROR_INVALID_PARAMETER);
goto cleanup;
}
-
- if ((cx == 0) || (cy == 0))
- {
- return GetStockObject(DEFAULT_BITMAP);
- }
+ }
+
+ /* Check if either width or height is 0 */
+ if ((cx == 0) || (cy == 0))
+ {
+ /* Return the default bitmap */
+ return GetStockObject(DEFAULT_BITMAP);
}
@@ -279,7 +295,10 @@
0);
cleanup:
- if (bConvertedInfo && pbmi) HeapFree(GetProcessHeap(), 0, (PVOID)pbmi);
+ if (bConvertedInfo)
+ {
+ HeapFree(GetProcessHeap(), 0, (PVOID)pbmi);
+ }
return hbmp;
}
Modified: branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/ntgdi/d…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c [iso-8859-1] Thu Jul 25 21:03:14
2013
@@ -56,14 +56,22 @@
}
else
{
+ /* This is a compressed format, no line width. */
pbmf->cjWidthBytes = 0;
- }
-
- /* Check compressed format and top-down */
- if ((pbmf->iFormat > BMF_32BPP) && (pbmf->sizel.cy < 0))
- {
- DPRINT1("Compressed bitmaps cannot be top-down.\n");
- return FALSE;
+
+ /* Check if we have a proper image size */
+ if (pbmf->cjImageSize == 0)
+ {
+ DPRINT1("Invalid format, need biSizeImage != 0\n");
+ return FALSE;
+ }
+
+ /* Check for top-down */
+ if (pbmf->sizel.cy < 0)
+ {
+ DPRINT1("Compressed bitmaps cannot be top-down.\n");
+ return FALSE;
+ }
}
// FIXME: check bitmap extensions / size
@@ -611,6 +619,7 @@
return NULL;
}
+ /* Get the DC surface */
psurfDC = pdc->dclevel.pSurface;
}
else
@@ -654,8 +663,8 @@
else
{
ppalBmp = CreateDIBPalette(pbmi, pdc, iUsage);
- }
- }
+ }
+ }
else
{
if (psurfDC)
@@ -674,8 +683,8 @@
GDIOBJ_vReferenceObjectByPointer(&ppalBmp->BaseObject);
}
- /* Allocate a surface for the bitmap */
- psurfBmp = SURFACE_AllocSurface(STYPE_BITMAP, cx, cy, iFormat, 0, 0, NULL);
+ /* Allocate a surface for the bitmap */
+ psurfBmp = SURFACE_AllocSurface(STYPE_BITMAP, cx, cy, iFormat, 0, 0, NULL);
if (psurfBmp)
{
/* Set new palette for the bitmap */
@@ -1310,7 +1319,7 @@
HANDLE hSecure;
ULONG cyDIB;
INT yTop, iResult;
-__debugbreak();
+//__debugbreak();
/* Check if parameters are valid */
if ((cNumScan == 0) || (cx >= INT_MAX) || (cy >= INT_MAX))
{