From 1bb98605476e93ff2fb9e51dc67255b5649d3d22 Mon Sep 17 00:00:00 2001 From: Huw D M Davies Date: Sun, 19 Sep 1999 12:04:17 +0000 Subject: [PATCH] Small DIB fixes. --- graphics/x11drv/dib.c | 33 ++++++++++++--------------------- objects/dib.c | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/graphics/x11drv/dib.c b/graphics/x11drv/dib.c index c2678155673..4edfe0ea31a 100644 --- a/graphics/x11drv/dib.c +++ b/graphics/x11drv/dib.c @@ -278,19 +278,18 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, RGBQUAD *colors, PALETTEENTRY *srccolors, XImage *bmpImage ) { - DWORD x; - int h; - BYTE *bits; + DWORD x; + int h; + BYTE *bits; /* 32 bit aligned */ DWORD linebytes = ((dstwidth + 31) & ~31) / 8; - if (lines < 0 ) - { - lines = -lines; - dstbits = dstbits + ( linebytes * lines-1 ); - linebytes = -linebytes; - } + if (lines < 0 ) { + lines = -lines; + dstbits = dstbits + linebytes * (lines - 1); + linebytes = -linebytes; + } bits = dstbits; @@ -1666,7 +1665,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, if (lines < 0 ) { lines = -lines; - srcbits = srcbits + ( linebytes * lines-1 ); + srcbits = srcbits + linebytes * (lines - 1); linebytes = -linebytes; } @@ -2853,7 +2852,6 @@ INT X11DRV_DIB_GetDIBits( X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib; X11DRV_DIB_IMAGEBITS_DESCR descr; PALETTEOBJ * palette; - BYTE *bbits = (BYTE*)bits; TRACE_(bitmap)("%u scanlines of (%i,%i) -> (%i,%i) starting from %u\n", lines, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight, @@ -2906,16 +2904,12 @@ INT X11DRV_DIB_GetDIBits( descr.yDest = 0; descr.width = bmp->bitmap.bmWidth; descr.height = bmp->bitmap.bmHeight; - descr.colorMap = info->bmiColors; + descr.colorMap = info->bmiColors; if (dib) - { - descr.useShm = (dib->shminfo.shmid != -1); - } + descr.useShm = (dib->shminfo.shmid != -1); else - { descr.useShm = FALSE; - } EnterCriticalSection( &X11DRV_CritSection ); @@ -2925,14 +2919,11 @@ INT X11DRV_DIB_GetDIBits( LeaveCriticalSection( &X11DRV_CritSection ); if(info->bmiHeader.biSizeImage == 0) /* Fill in biSizeImage */ - info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes( + info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes( info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biBitCount ); - if(bbits - (BYTE *)bits > info->bmiHeader.biSizeImage) - ERR_(bitmap)("Buffer overrun. Please investigate.\n"); - info->bmiHeader.biCompression = 0; GDI_HEAP_UNLOCK( dc->w.hPalette ); diff --git a/objects/dib.c b/objects/dib.c index 8ddbe1e5cdd..8166fa2c710 100644 --- a/objects/dib.c +++ b/objects/dib.c @@ -540,12 +540,12 @@ INT WINAPI GetDIBits( /*FIXME: Only RGB dibs supported for now */ int srcwidth = bmp->dib->dsBm.bmWidth, srcwidthb = bmp->dib->dsBm.bmWidthBytes; int dstwidthb = DIB_GetDIBWidthBytes( info->bmiHeader.biWidth, info->bmiHeader.biBitCount ); - LPVOID dbits = bits, sbits = bmp->dib->dsBm.bmBits + (startscan * srcwidthb); + LPBYTE dbits = bits, sbits = bmp->dib->dsBm.bmBits + (startscan * srcwidthb); int x, y; if ((info->bmiHeader.biHeight < 0) ^ (bmp->dib->dsBmih.biHeight < 0)) { - dbits = bits + (dstwidthb * (lines-1)); + dbits = (LPBYTE)bits + (dstwidthb * (lines-1)); dstwidthb = -dstwidthb; } @@ -571,7 +571,7 @@ INT WINAPI GetDIBits( case 24: /* 24 bpp srcDIB -> 16 bpp dstDIB */ { - LPBYTE srcbits = (LPBYTE)sbits; + LPBYTE srcbits = sbits; for( y = 0; y < lines; y++) { for( x = 0; x < srcwidth; x++ ) @@ -579,7 +579,7 @@ INT WINAPI GetDIBits( (((WORD)*srcbits++ << 2) & gmask) | (((WORD)*srcbits++ << 7) & rmask); dstbits = (LPWORD)(dbits+=dstwidthb); - srcbits = (LPBYTE)(sbits += srcwidthb); + srcbits = (sbits += srcwidthb); } } break; @@ -595,8 +595,8 @@ INT WINAPI GetDIBits( *dstbits++ = (WORD)(((val >> 19) & bmask) | ((val >> 6) & gmask) | ((val << 7) & rmask)); } - dstbits=(LPWORD)(dbits+=dstwidthb); - srcbits = (LPDWORD)(sbits += srcwidthb); + dstbits = (LPWORD)(dbits+=dstwidthb); + srcbits = (LPDWORD)(sbits+=srcwidthb); } } break; @@ -611,7 +611,7 @@ INT WINAPI GetDIBits( case 24: /* 24 bpp dstDIB */ { - LPBYTE dstbits = (LPBYTE)dbits; + LPBYTE dstbits = dbits; switch(bmp->dib->dsBm.bmBitsPixel) { @@ -628,7 +628,7 @@ INT WINAPI GetDIBits( *dstbits++ = (BYTE)(((val >> 2) & 0xf8) | ((val >> 7) & 0x07)); *dstbits++ = (BYTE)(((val << 3) & 0xf8) | ((val >> 2) & 0x07)); } - dstbits=(LPBYTE)(dbits+=dstwidthb); + dstbits = (LPBYTE)(dbits+=dstwidthb); srcbits = (LPWORD)(sbits+=srcwidthb); } } @@ -686,22 +686,22 @@ INT WINAPI GetDIBits( ((val << 6) & 0xf800) | ((val << 1) & 0x0700) | ((val << 19) & 0xf800) | ((val << 14) & 0x070000); } - dstbits=(dbits+=dstwidthb); - srcbits=(sbits+=srcwidthb); + dstbits=(LPDWORD)(dbits+=dstwidthb); + srcbits=(LPWORD)(sbits+=srcwidthb); } } break; case 24: /* 24 bpp srcDIB -> 32 bpp dstDIB */ { - LPBYTE srcbits = (LPBYTE)sbits; + LPBYTE srcbits = sbits; for( y = 0; y < lines; y++) { for( x = 0; x < srcwidth; x++ ) *dstbits++ = ((DWORD)*srcbits++ & rmask) | (((DWORD)*srcbits++ << 8) & gmask) | (((DWORD)*srcbits++ << 7) & bmask); - dstbits=(dbits+=dstwidthb); + dstbits=(LPDWORD)(dbits+=dstwidthb); srcbits=(sbits+=srcwidthb); } }