[ros-diffs] [greatlrd] 33427: Remove old hack I implmeneted in NtGdiCreateBitmap it is height == 0 or width == 0, it create 1x1 1Bpp we can remove this hack now. BugFix CreateBitmapIndirect, the code have been tested in reactos and windows, include abiword 1. the bmWidthBytes must be align with 2 and it must be 2 or higher like windows xp/2003 and msdn 2. Do not do direcly call to NtGdiCreateBitmap use CreateBitmap so we getting same behoir for 1x1 1Bpp bitmap. 3. This will also take care of handle leaks for bitmap that being create with height = 0, width = 0 and do not delete the object. 4. Windowss does not check if the incoming bitmap is NULL, this behoir to make it more compatible.

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Sun May 11 10:20:18 CEST 2008


Author: greatlrd
Date: Sun May 11 03:20:18 2008
New Revision: 33427

URL: http://svn.reactos.org/svn/reactos?rev=33427&view=rev
Log:
Remove old hack I implmeneted in NtGdiCreateBitmap it is height == 0 or width == 0, it create 1x1 1Bpp we can remove this hack now. 
BugFix CreateBitmapIndirect, the code have been tested in reactos and windows, include abiword 
1. the bmWidthBytes must be align with 2 and it must be 2 or higher like windows xp/2003 and msdn
2. Do not do direcly call to NtGdiCreateBitmap use CreateBitmap so we getting same behoir for 1x1 1Bpp bitmap.
3. This will also take care of handle leaks for bitmap that being create with height = 0,  width = 0 and do not delete the object.
4. Windowss does not check if the incoming bitmap is NULL, this behoir to make it more compatible. 




Modified:
    trunk/reactos/dll/win32/gdi32/objects/bitmap.c
    trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c

Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/bitmap.c?rev=33427&r1=33426&r2=33427&view=diff
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] Sun May 11 03:20:18 2008
@@ -187,15 +187,22 @@
 HBITMAP WINAPI
 CreateBitmapIndirect(const BITMAP *pbm)
 {
-   if (pbm)
+   HBITMAP bitmap = NULL;
+
+   /* Note windows xp/2003 does not check if pbm is NULL or not */
+   if ( (pbm->bmWidthBytes != 0) &&
+        (!(pbm->bmWidthBytes & 1)) )
+
    {
-      return NtGdiCreateBitmap(pbm->bmWidth,
-                               pbm->bmHeight,
-                               pbm->bmPlanes,
-                               pbm->bmBitsPixel,
-                               pbm->bmBits);
+        
+      bitmap = CreateBitmap(pbm->bmWidth,
+                            pbm->bmHeight,
+                            pbm->bmPlanes,
+                            pbm->bmBitsPixel,
+                            pbm->bmBits);
    }
-   return NULL;
+
+   return bitmap;
 }
 
 HBITMAP WINAPI

Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c?rev=33427&r1=33426&r2=33427&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Sun May 11 03:20:18 2008
@@ -112,14 +112,8 @@
          ProbeForRead(pUnsafeBits, cjBits, 1);
       }
 
-      if (0 == Width || 0 == Height)
-      {
-         hBitmap = IntGdiCreateBitmap (1, 1, 1, 1, NULL);
-      }
-      else
-      {
-        hBitmap = IntGdiCreateBitmap(Width, Height, Planes, BitsPixel, pUnsafeBits);
-      }
+      hBitmap = IntGdiCreateBitmap(Width, Height, Planes, BitsPixel, pUnsafeBits);
+
    }
    _SEH_HANDLE
    {



More information about the Ros-diffs mailing list