[WIN32K]
[reactos.git] / subsystems / win32 / win32k / eng / surface.c
index ab9f0d2..46f96d8 100644 (file)
@@ -200,16 +200,17 @@ SURFACE_bSetBitmapBits(
     cBitsPixel = gajBitsPerFormat[pso->iBitmapFormat];
 
     /* Is a width in bytes given? */
-    if (ulWidth)
-    {
-        /* Align the width (Windows compatibility) */
-        ulWidth = ((((ulWidth << 3) / cBitsPixel) * cBitsPixel + 31) & ~31) >> 3;
-    }
-    else
+    if (!ulWidth)
     {
         /* Calculate width from the bitmap width in pixels */
-        ulWidth = ((pso->sizlBitmap.cx * cBitsPixel + 31) & ~31) >> 3;
+        ulWidth = DIB_GetDIBWidthBytes(psurf->SurfObj.sizlBitmap.cx, cBitsPixel);
     }
+       else
+       {
+               /* Align the width (windows compatibility, drivers expect that) */
+       ulWidth = ((((ulWidth << 3) / cBitsPixel) * cBitsPixel + 31) & ~31) >> 3;
+       }
+
 
     /* Calculate the bitmap size in bytes */
     pso->cjBits = ulWidth * pso->sizlBitmap.cy;