[ros-diffs] [tkreuzer] 56569: [WIN32K] Halfplement GreCreateDIBitmapInternal

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sat May 12 21:05:35 UTC 2012


Author: tkreuzer
Date: Sat May 12 21:05:35 2012
New Revision: 56569

URL: http://svn.reactos.org/svn/reactos?rev=56569&view=rev
Log:
[WIN32K]
Halfplement GreCreateDIBitmapInternal

Modified:
    branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c

Modified: branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c
URL: http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c?rev=56569&r1=56568&r2=56569&view=diff
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/ntgdi/dibitmap.c [iso-8859-1] Sat May 12 21:05:35 2012
@@ -565,7 +565,10 @@
     _In_ HANDLE hcmXform)
 {
     PDC pdc;
-    PSURFACE psurfDIB;
+    PSURFACE psurfDIB, psurfDC, psurfBmp;
+    ULONG iFormat;
+    PPALETTE ppalBmp;
+    HBITMAP hbmp;
 
     /* Check if we got a DC */
     if (hdc)
@@ -576,6 +579,8 @@
         {
             return NULL;
         }
+
+        psurfDC = pdc->dclevel.pSurface;
     }
     else
     {
@@ -593,6 +598,82 @@
                                        cjMaxBits);
     }
 
+
+    if (fInit & CBM_CREATDIB)
+    {
+        if (iUsage == 2) goto cleanup;
+
+        /* Need a DC for DIB_PAL_COLORS */
+        if ((iUsage == DIB_PAL_COLORS) && !pdc) goto cleanup;
+
+        iFormat = psurfDIB->SurfObj.iBitmapFormat;
+
+        if (psurfDIB)
+        {
+            ppalBmp = psurfDIB->ppal;
+            GDIOBJ_vReferenceObjectByPointer(&ppalBmp->BaseObject);
+        }
+        else
+        {
+            ppalBmp = CreateDIBPalette(pbmi, pdc, iUsage);
+        }
+    }
+    else
+    {
+        if (psurfDC)
+        {
+            /* Use the same format as the DC surface */
+            iFormat = psurfDC->SurfObj.iBitmapFormat;
+            ppalBmp = psurfDC->ppal;
+        }
+        else
+        {
+            __debugbreak();
+        }
+
+        GDIOBJ_vReferenceObjectByPointer(&ppalBmp->BaseObject);
+    }
+
+    /* 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 */
+        SURFACE_vSetPalette(psurfBmp, ppalBmp);
+
+        if (pjInit)
+        {
+            RECTL rclDest = {0, 0, cx, cy};
+            POINTL ptlSrc = {0, 0};
+            EXLATEOBJ exlo;
+
+            /* Initialize XLATEOBJ */
+            EXLATEOBJ_vInitialize(&exlo,
+                                  psurfBmp->ppal,
+                                  psurfDIB->ppal,
+                                  RGB(0xff, 0xff, 0xff),
+                                  RGB(0xff, 0xff, 0xff),
+                                  RGB(0x00, 0x00, 0x00));
+
+            EngCopyBits(&psurfBmp->SurfObj,
+                        &psurfDIB->SurfObj,
+                        NULL,
+                        &exlo.xlo,
+                        &rclDest,
+                        &ptlSrc);
+
+            EXLATEOBJ_vCleanup(&exlo);
+        }
+
+        /* Get the bitmap handle and unlock the bitmap */
+        hbmp = psurfBmp->BaseObject.hHmgr;
+        SURFACE_UnlockSurface(psurfBmp);
+    }
+
+
+cleanup:
+
+    if (ppalBmp) PALETTE_ShareUnlockPalette(ppalBmp);
 
     return 0;
 }




More information about the Ros-diffs mailing list