Author: tkreuzer
Date: Tue Jul 23 15:31:43 2013
New Revision: 59564
URL: 
http://svn.reactos.org/svn/reactos?rev=59564&view=rev
Log:
[WIN32K]
Fix some bugs related to DIB brushes.
Modified:
    branches/dib_rewrite/win32ss/gdi/ntgdi/brush.c
    branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c
Modified: branches/dib_rewrite/win32ss/gdi/ntgdi/brush.c
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/ntgdi/b…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/ntgdi/brush.c      [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/ntgdi/brush.c      [iso-8859-1] Tue Jul 23 15:31:43
2013
@@ -424,6 +424,13 @@
         return NULL;
     }
+    /* Check for undocumented case 2 */
+    if (iUsage == 2)
+    {
+        /* Tests show that this results in a hollow/null brush */
+        return GreCreateNullBrush();
+    }
+
     /* Allocate a buffer large enough to hold the complete packed DIB */
     pvSaveDIB = ExAllocatePoolWithTag(PagedPool, cjDIBSize, TAG_DIB);
     if (pvSaveDIB == NULL)
@@ -468,18 +475,22 @@
        entries directly, instead we need to create a fake palette containing
        pal indices, which is converted into a real palette when the brush
        is realized. */
-    if (iUsage == DIB_PAL_COLORS) iUsage = DIB_PAL_BRUSHHACK;
+    if (iUsage == DIB_PAL_COLORS)
+    {
+        iUsage = DIB_PAL_BRUSHHACK;
+        flAttr |= BR_IS_DIBPALCOLORS;
+    }
     /* Create the pattern bitmap from the DIB. */
     hbmPattern = GreCreateDIBitmapInternal(NULL,
                                            pbmi->bmiHeader.biWidth,
                                            abs(pbmi->bmiHeader.biHeight),
-                                           CBM_INIT,
+                                           CBM_INIT | CBM_CREATDIB,
                                            pvSafeBits,
                                            pbmi,
                                            iUsage,// FIXME!!!
+                                           cjDIBSize - cjInfoSize,
                                            0,
-                                           cjDIBSize - cjInfoSize,
                                            NULL);
     /* Free the buffer already */
@@ -492,9 +503,6 @@
         return NULL;
     }
-    /* Remember if the palette consists of palette indices */
-    if (iUsage == DIB_PAL_COLORS) flAttr |= BR_IS_DIBPALCOLORS;
-
     /* Call the internal worker function */
     return GreCreateBrushInternal(0, hbmPattern, pvPackedDIB, 0, flAttr);
 }
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] Tue Jul 23 15:31:43
2013
@@ -286,7 +286,7 @@
                    the number of colors in the DC palette */
                 WORD wIndex = pwColors[i] % ppalDC->NumColors;
-                /* USe the RGB value from the DC palette */
+                /* Use the RGB value from the DC palette */
                 crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, wIndex);
                 PALETTE_vSetRGBColorForIndex(ppal, i, crColor);
             }
@@ -644,6 +644,7 @@
         if ((iUsage == DIB_PAL_COLORS) && !pdc) goto cleanup;
         iFormat = psurfDIB->SurfObj.iBitmapFormat;
+        if (iFormat > BMF_32BPP) goto cleanup;
         if (psurfDIB)
         {
@@ -1354,7 +1355,7 @@
     yTop = cyDIB - (iStartScan + cNumScan);
     /* Bail out if the intersecion between scanlines and copy area is empty */
-    if ((ySrc > yTop + cNumScan) || (ySrc + (INT)cy < yTop)) goto leave;
+    if ((ySrc > yTop + (INT)cNumScan) || (ySrc + (INT)cy < yTop)) goto leave;
     /* Check if the copy area starts below or at the topmost scanline */
     if (ySrc >= yTop)