Author: tkreuzer Date: Sun Jun 6 11:09:04 2010 New Revision: 47618
URL: http://svn.reactos.org/svn/reactos?rev=47618&view=rev Log: [WIN32K] Add Windows compatible alignment code.
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1] Sun Jun 6 11:09:04 2010 @@ -221,14 +221,25 @@ { SURFOBJ *pso = &psurf->SurfObj; PVOID pvSection; + UCHAR cBitsPixel;
/* Only bitmaps can have bits */ ASSERT(psurf->SurfObj.iType == STYPE_BITMAP);
- /* If no width is given, calculate it */ - if (!ulWidth) - ulWidth = DIB_GetDIBWidthBytes(pso->sizlBitmap.cx, - BitsPerFormat(pso->iBitmapFormat)); + /* Get bits per pixel from the format */ + 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 + { + /* Calculate width from the bitmap width in pixels */ + ulWidth = ((pso->sizlBitmap.cx * cBitsPixel + 31) & ~31) >> 3; + }
/* Calculate the bitmap size in bytes */ pso->cjBits = ulWidth * pso->sizlBitmap.cy;