[ros-diffs] [tkreuzer] 54024: [WIN32K] use GreCreateBitmapEx in IntSetDIBits as well to handle RLE images. Fixes bug 6388

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Thu Oct 6 13:38:45 UTC 2011


Author: tkreuzer
Date: Thu Oct  6 13:38:45 2011
New Revision: 54024

URL: http://svn.reactos.org/svn/reactos?rev=54024&view=rev
Log:
[WIN32K]
use GreCreateBitmapEx in IntSetDIBits as well to handle RLE images. Fixes bug 6388

Modified:
    trunk/reactos/subsystems/win32/win32k/objects/dibobj.c

Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/dibobj.c?rev=54024&r1=54023&r2=54024&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Thu Oct  6 13:38:45 2011
@@ -250,21 +250,26 @@
     INT         result = 0;
     RECT		rcDst;
     POINTL		ptSrc;
-    PVOID		pvBits;
     EXLATEOBJ	exlo;
-
-    SourceBitmap = DIB_CreateDIBSection(DC, bmi, ColorUse, &pvBits, NULL, 0, 0);
-    if (0 == SourceBitmap)
-    {
-        DPRINT1("Error : Could not create a DIBSection.\n");
+    HPALETTE    hpalDIB = 0;
+    PPALETTE    ppalDIB = 0;
+
+    SourceBitmap = GreCreateBitmapEx(bmi->bmiHeader.biWidth,
+                                     ScanLines,
+                                     0,
+                                     BitmapFormat(bmi->bmiHeader.biBitCount,
+                                                  bmi->bmiHeader.biCompression),
+                                     bmi->bmiHeader.biHeight < 0 ? BMF_TOPDOWN : 0,
+                                     bmi->bmiHeader.biSizeImage,
+                                     (PVOID)Bits,
+                                     0);
+    if (!SourceBitmap)
+    {
+        DPRINT1("Error: Could not create a bitmap.\n");
         EngSetLastError(ERROR_NO_SYSTEM_RESOURCES);
         return 0;
     }
 
-    RtlCopyMemory(pvBits, Bits, DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth,
-                  bmi->bmiHeader.biHeight,
-                  bmi->bmiHeader.biBitCount));
-
     psurfDst = SURFACE_ShareLockSurface(hBitmap);
     psurfSrc = SURFACE_ShareLockSurface(SourceBitmap);
 
@@ -273,17 +278,37 @@
         DPRINT1("Error, could not lock surfaces\n");
         goto cleanup;
     }
+
+    /* Create a palette for the DIB */
+    hpalDIB = BuildDIBPalette(bmi);
+    if (!hpalDIB)
+    {
+        EngSetLastError(ERROR_NO_SYSTEM_RESOURCES);
+        goto cleanup;
+    }
+
+    /* Lock the DIB palette */
+    ppalDIB = PALETTE_ShareLockPalette(hpalDIB);
+    if (!ppalDIB)
+    {
+        EngSetLastError(ERROR_INVALID_HANDLE);
+        goto cleanup;
+    }
+
+    /* Initialize EXLATEOBJ */
+    EXLATEOBJ_vInitialize(&exlo,
+                          ppalDIB,
+                          psurfDst->ppal,
+                          RGB(0xff, 0xff, 0xff),
+                          RGB(0xff, 0xff, 0xff), //DC->pdcattr->crBackgroundClr,
+                          0); // DC->pdcattr->crForegroundClr);
 
     rcDst.top = StartScan;
     rcDst.left = 0;
     rcDst.bottom = rcDst.top + ScanLines;
     rcDst.right = psurfDst->SurfObj.sizlBitmap.cx;
-
     ptSrc.x = 0;
     ptSrc.y = 0;
-
-    /* 1bpp bitmaps have 0 for white, 1 for black */
-    EXLATEOBJ_vInitialize(&exlo, psurfSrc->ppal, psurfDst->ppal, 0xFFFFFF, 0xFFFFFF, 0);
 
     result = IntEngCopyBits(&psurfDst->SurfObj,
                             &psurfSrc->SurfObj,
@@ -297,14 +322,10 @@
     EXLATEOBJ_vCleanup(&exlo);
 
 cleanup:
-    if(psurfSrc)
-    {
-        SURFACE_ShareUnlockSurface(psurfSrc);
-    }
-    if(psurfDst)
-    {
-        SURFACE_ShareUnlockSurface(psurfDst);
-    }
+    if (ppalDIB) PALETTE_ShareUnlockPalette(ppalDIB);
+    if (hpalDIB) GreDeleteObject(hpalDIB);
+    if(psurfSrc) SURFACE_ShareUnlockSurface(psurfSrc);
+    if(psurfDst) SURFACE_ShareUnlockSurface(psurfDst);
     GreDeleteObject(SourceBitmap);
 
     return result;




More information about the Ros-diffs mailing list