[ros-diffs] [fireball] 42301: - Actually do set bitmap bits if RosGdiCreateBitmap was provided with bits. - Add helper GreSetBitmapBits function implementation.

fireball at svn.reactos.org fireball at svn.reactos.org
Thu Jul 30 15:09:59 CEST 2009


Author: fireball
Date: Thu Jul 30 15:09:59 2009
New Revision: 42301

URL: http://svn.reactos.org/svn/reactos?rev=42301&view=rev
Log:
- Actually do set bitmap bits if RosGdiCreateBitmap was provided with bits.
- Add helper GreSetBitmapBits function implementation.

Modified:
    branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c
    branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
    branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h

Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c?rev=42301&r1=42300&r2=42301&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] Thu Jul 30 15:09:59 2009
@@ -51,6 +51,8 @@
     HBITMAP hBitmap;
     SIZEL slSize;
     ULONG ulFormat;
+    ULONG ulFlags = 0;
+    PSURFACE pSurface;
 
     DPRINT("RosGdiCreateBitmap %dx%d %d bpp, bmBits %p\n", pBitmap->bmWidth, pBitmap->bmHeight, pBitmap->bmBitsPixel, bmBits);
 
@@ -60,16 +62,33 @@
 
     /* Convert format */
     ulFormat = GrepBitmapFormat(pBitmap->bmBitsPixel, BI_RGB);
+
+    /* Set flags */
+    if (bmBits) ulFlags |= BMF_NOZEROINIT;
+    if (pBitmap->bmHeight < 0) ulFlags |= BMF_TOPDOWN;
 
     /* Call GRE to create the bitmap object */
     hBitmap = GreCreateBitmap(slSize,
                               pBitmap->bmWidthBytes,
                               ulFormat,
-                              (pBitmap->bmHeight < 0 ? BMF_TOPDOWN : 0),
+                              ulFlags,
                               NULL);
 
     /* Return failure if no bitmap was created */
     if (!hBitmap) return FALSE;
+
+    /* Set its bits if any */
+    if (bmBits)
+    {
+        /* Get the object pointer */
+        pSurface = GDI_GetObjPtr(hBitmap, (SHORT)GDI_OBJECT_TYPE_BITMAP);
+
+        /* Copy bits */
+        GreSetBitmapBits(pSurface, pSurface->SurfObj.cjBits, bmBits);
+
+        /* Release the surface */
+        GDI_ReleaseObj(hBitmap);
+    }
 
     /* Map handles */
     GDI_AddHandleMapping(hBitmap, hUserBitmap);

Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c?rev=42301&r1=42300&r2=42301&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1] Thu Jul 30 15:09:59 2009
@@ -235,4 +235,18 @@
     return ulBytes;
 }
 
-
+LONG FASTCALL
+GreSetBitmapBits(PSURFACE pSurf, ULONG ulBytes, PVOID pBits)
+{
+    /* Check ulBytes */
+    if (!ulBytes) return 0;
+
+    /* Don't copy more bytes than the surface has */
+    ulBytes = min(ulBytes, pSurf->SurfObj.cjBits);
+
+    /* Copy actual bits */
+    RtlCopyMemory(pSurf->SurfObj.pvBits, pBits, ulBytes);
+
+    /* Return amount copied */
+    return ulBytes;
+}

Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h?rev=42301&r1=42300&r2=42301&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h [iso-8859-1] Thu Jul 30 15:09:59 2009
@@ -25,6 +25,9 @@
 LONG FASTCALL
 GreGetBitmapBits(PSURFACE pSurf, ULONG ulBytes, PVOID pBits);
 
+LONG FASTCALL
+GreSetBitmapBits(PSURFACE pSurf, ULONG ulBytes, PVOID pBits);
+
 INT FASTCALL
 BITMAP_GetWidthBytes(INT bmWidth, INT bpp);
 




More information about the Ros-diffs mailing list