Add macros WIDTH_BYTES_ALIGN16/32

svn path=/branches/reactos-yarotows/; revision=48675
This commit is contained in:
Timo Kreuzer 2010-09-01 12:04:31 +00:00
parent ce75f117fd
commit 61c05f8d3d
2 changed files with 9 additions and 6 deletions

View file

@ -200,18 +200,17 @@ SURFACE_bSetBitmapBits(
cBitsPixel = gajBitsPerFormat[pso->iBitmapFormat];
/* Is a width in bytes given? */
if (!ulWidth)
if (ulWidth)
{
/* Calculate width from the bitmap width in pixels */
ulWidth = DIB_GetDIBWidthBytes(psurf->SurfObj.sizlBitmap.cx, cBitsPixel);
/* Align the width (Windows compatibility, drivers expect that) */
ulWidth = WIDTH_BYTES_ALIGN32((ulWidth << 3) / cBitsPixel, cBitsPixel);
}
else
{
/* Align the width (windows compatibility, drivers expect that) */
ulWidth = ((((ulWidth << 3) / cBitsPixel) * cBitsPixel + 31) & ~31) >> 3;
/* Calculate width from the bitmap width in pixels */
ulWidth = WIDTH_BYTES_ALIGN32(pso->sizlBitmap.cx, cBitsPixel);
}
/* Calculate the bitmap size in bytes */
pso->cjBits = ulWidth * pso->sizlBitmap.cy;

View file

@ -128,3 +128,7 @@ SURFACE_bSetBitmapBits(
ULONG FASTCALL BitmapFormat (WORD Bits, DWORD Compression);
extern UCHAR gajBitsPerFormat[];
#define BitsPerFormat(Format) gajBitsPerFormat[Format]
#define WIDTH_BYTES_ALIGN32(cx, bpp) ((((cx) * (bpp) + 31) & ~31) >> 3)
#define WIDTH_BYTES_ALIGN16(cx, bpp) ((((cx) * (bpp) + 15) & ~15) >> 3)