Commit dd8922f2 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

Repect the width of both the src and dst when calculating how many

pixels to copy in a dib <-> bmp operation.
parent b4620226
...@@ -522,9 +522,10 @@ INT WINAPI GetDIBits( ...@@ -522,9 +522,10 @@ INT WINAPI GetDIBits(
{ {
/*FIXME: Only RGB dibs supported for now */ /*FIXME: Only RGB dibs supported for now */
unsigned int srcwidth = bmp->dib->dsBm.bmWidth, srcwidthb = bmp->dib->dsBm.bmWidthBytes; unsigned int srcwidth = bmp->dib->dsBm.bmWidth, srcwidthb = bmp->dib->dsBm.bmWidthBytes;
unsigned int dstwidth = info->bmiHeader.biWidth;
int dstwidthb = DIB_GetDIBWidthBytes( info->bmiHeader.biWidth, info->bmiHeader.biBitCount ); int dstwidthb = DIB_GetDIBWidthBytes( info->bmiHeader.biWidth, info->bmiHeader.biBitCount );
LPBYTE dbits = bits, sbits = (LPBYTE) bmp->dib->dsBm.bmBits + (startscan * srcwidthb); LPBYTE dbits = bits, sbits = (LPBYTE) bmp->dib->dsBm.bmBits + (startscan * srcwidthb);
unsigned int x, y; unsigned int x, y, width, widthb;
if ((info->bmiHeader.biHeight < 0) ^ (bmp->dib->dsBmih.biHeight < 0)) if ((info->bmiHeader.biHeight < 0) ^ (bmp->dib->dsBmih.biHeight < 0))
{ {
...@@ -546,9 +547,10 @@ INT WINAPI GetDIBits( ...@@ -546,9 +547,10 @@ INT WINAPI GetDIBits(
case 16: /* 16 bpp srcDIB -> 16 bpp dstDIB */ case 16: /* 16 bpp srcDIB -> 16 bpp dstDIB */
{ {
widthb = min(srcwidthb, abs(dstwidthb));
/* FIXME: BI_BITFIELDS not supported yet */ /* FIXME: BI_BITFIELDS not supported yet */
for (y = 0; y < lines; y++, dbits+=dstwidthb, sbits+=srcwidthb) for (y = 0; y < lines; y++, dbits+=dstwidthb, sbits+=srcwidthb)
memcpy(dbits, sbits, srcwidthb); memcpy(dbits, sbits, widthb);
} }
break; break;
...@@ -556,8 +558,9 @@ INT WINAPI GetDIBits( ...@@ -556,8 +558,9 @@ INT WINAPI GetDIBits(
{ {
LPBYTE srcbits = sbits; LPBYTE srcbits = sbits;
width = min(srcwidth, dstwidth);
for( y = 0; y < lines; y++) { for( y = 0; y < lines; y++) {
for( x = 0; x < srcwidth; x++, srcbits += 3) for( x = 0; x < width; x++, srcbits += 3)
*dstbits++ = ((srcbits[0] >> 3) & bmask) | *dstbits++ = ((srcbits[0] >> 3) & bmask) |
(((WORD)srcbits[1] << 2) & gmask) | (((WORD)srcbits[1] << 2) & gmask) |
(((WORD)srcbits[2] << 7) & rmask); (((WORD)srcbits[2] << 7) & rmask);
...@@ -573,8 +576,9 @@ INT WINAPI GetDIBits( ...@@ -573,8 +576,9 @@ INT WINAPI GetDIBits(
LPDWORD srcbits = (LPDWORD)sbits; LPDWORD srcbits = (LPDWORD)sbits;
DWORD val; DWORD val;
width = min(srcwidth, dstwidth);
for( y = 0; y < lines; y++) { for( y = 0; y < lines; y++) {
for( x = 0; x < srcwidth; x++ ) { for( x = 0; x < width; x++ ) {
val = *srcbits++; val = *srcbits++;
*dstbits++ = (WORD)(((val >> 3) & bmask) | ((val >> 6) & gmask) | *dstbits++ = (WORD)(((val >> 3) & bmask) | ((val >> 6) & gmask) |
((val >> 9) & rmask)); ((val >> 9) & rmask));
...@@ -604,9 +608,10 @@ INT WINAPI GetDIBits( ...@@ -604,9 +608,10 @@ INT WINAPI GetDIBits(
LPWORD srcbits = (LPWORD)sbits; LPWORD srcbits = (LPWORD)sbits;
WORD val; WORD val;
width = min(srcwidth, dstwidth);
/* FIXME: BI_BITFIELDS not supported yet */ /* FIXME: BI_BITFIELDS not supported yet */
for( y = 0; y < lines; y++) { for( y = 0; y < lines; y++) {
for( x = 0; x < srcwidth; x++ ) { for( x = 0; x < width; x++ ) {
val = *srcbits++; val = *srcbits++;
*dstbits++ = (BYTE)(((val << 3) & 0xf8) | ((val >> 2) & 0x07)); *dstbits++ = (BYTE)(((val << 3) & 0xf8) | ((val >> 2) & 0x07));
*dstbits++ = (BYTE)(((val >> 2) & 0xf8) | ((val >> 7) & 0x07)); *dstbits++ = (BYTE)(((val >> 2) & 0xf8) | ((val >> 7) & 0x07));
...@@ -620,8 +625,9 @@ INT WINAPI GetDIBits( ...@@ -620,8 +625,9 @@ INT WINAPI GetDIBits(
case 24: /* 24 bpp srcDIB -> 24 bpp dstDIB */ case 24: /* 24 bpp srcDIB -> 24 bpp dstDIB */
{ {
widthb = min(srcwidthb, abs(dstwidthb));
for (y = 0; y < lines; y++, dbits+=dstwidthb, sbits+=srcwidthb) for (y = 0; y < lines; y++, dbits+=dstwidthb, sbits+=srcwidthb)
memcpy(dbits, sbits, srcwidthb); memcpy(dbits, sbits, widthb);
} }
break; break;
...@@ -629,8 +635,9 @@ INT WINAPI GetDIBits( ...@@ -629,8 +635,9 @@ INT WINAPI GetDIBits(
{ {
LPBYTE srcbits = (LPBYTE)sbits; LPBYTE srcbits = (LPBYTE)sbits;
width = min(srcwidth, dstwidth);
for( y = 0; y < lines; y++) { for( y = 0; y < lines; y++) {
for( x = 0; x < srcwidth; x++, srcbits++ ) { for( x = 0; x < width; x++, srcbits++ ) {
*dstbits++ = *srcbits++; *dstbits++ = *srcbits++;
*dstbits++ = *srcbits++; *dstbits++ = *srcbits++;
*dstbits++ = *srcbits++; *dstbits++ = *srcbits++;
...@@ -661,9 +668,10 @@ INT WINAPI GetDIBits( ...@@ -661,9 +668,10 @@ INT WINAPI GetDIBits(
LPWORD srcbits = (LPWORD)sbits; LPWORD srcbits = (LPWORD)sbits;
DWORD val; DWORD val;
width = min(srcwidth, dstwidth);
/* FIXME: BI_BITFIELDS not supported yet */ /* FIXME: BI_BITFIELDS not supported yet */
for( y = 0; y < lines; y++) { for( y = 0; y < lines; y++) {
for( x = 0; x < srcwidth; x++ ) { for( x = 0; x < width; x++ ) {
val = (DWORD)*srcbits++; val = (DWORD)*srcbits++;
*dstbits++ = ((val << 3) & 0xf8) | ((val >> 2) & 0x07) | *dstbits++ = ((val << 3) & 0xf8) | ((val >> 2) & 0x07) |
((val << 6) & 0xf800) | ((val << 1) & 0x0700) | ((val << 6) & 0xf800) | ((val << 1) & 0x0700) |
...@@ -679,8 +687,9 @@ INT WINAPI GetDIBits( ...@@ -679,8 +687,9 @@ INT WINAPI GetDIBits(
{ {
LPBYTE srcbits = sbits; LPBYTE srcbits = sbits;
width = min(srcwidth, dstwidth);
for( y = 0; y < lines; y++) { for( y = 0; y < lines; y++) {
for( x = 0; x < srcwidth; x++, srcbits+=3 ) for( x = 0; x < width; x++, srcbits+=3 )
*dstbits++ = ((DWORD)*srcbits) & 0x00ffffff; *dstbits++ = ((DWORD)*srcbits) & 0x00ffffff;
dstbits=(LPDWORD)(dbits+=dstwidthb); dstbits=(LPDWORD)(dbits+=dstwidthb);
srcbits=(sbits+=srcwidthb); srcbits=(sbits+=srcwidthb);
...@@ -688,11 +697,13 @@ INT WINAPI GetDIBits( ...@@ -688,11 +697,13 @@ INT WINAPI GetDIBits(
} }
break; break;
case 32: /* 32 bpp srcDIB -> 16 bpp dstDIB */ case 32: /* 32 bpp srcDIB -> 32 bpp dstDIB */
{ {
widthb = min(srcwidthb, abs(dstwidthb));
/* FIXME: BI_BITFIELDS not supported yet */ /* FIXME: BI_BITFIELDS not supported yet */
for (y = 0; y < lines; y++, dbits+=dstwidthb, sbits+=srcwidthb) for (y = 0; y < lines; y++, dbits+=dstwidthb, sbits+=srcwidthb) {
memcpy(dbits, sbits, srcwidthb); memcpy(dbits, sbits, widthb);
}
} }
break; break;
......
...@@ -400,7 +400,7 @@ static void X11DRV_DIB_SetImageBits_1( int lines, const BYTE *srcbits, ...@@ -400,7 +400,7 @@ static void X11DRV_DIB_SetImageBits_1( int lines, const BYTE *srcbits,
DWORD srcwidth, DWORD dstwidth, int left, DWORD srcwidth, DWORD dstwidth, int left,
int *colors, XImage *bmpImage, DWORD linebytes) int *colors, XImage *bmpImage, DWORD linebytes)
{ {
int h; int h, width;
const BYTE* srcbyte; const BYTE* srcbyte;
BYTE srcval, extra; BYTE srcval, extra;
DWORD i, x; DWORD i, x;
...@@ -416,12 +416,13 @@ static void X11DRV_DIB_SetImageBits_1( int lines, const BYTE *srcbits, ...@@ -416,12 +416,13 @@ static void X11DRV_DIB_SetImageBits_1( int lines, const BYTE *srcbits,
dstwidth += extra; dstwidth += extra;
} }
srcbits += left >> 3; srcbits += left >> 3;
width = min(srcwidth, dstwidth);
/* ==== pal 1 dib -> any bmp format ==== */ /* ==== pal 1 dib -> any bmp format ==== */
for (h = lines-1; h >=0; h--) { for (h = lines-1; h >=0; h--) {
srcbyte=srcbits; srcbyte=srcbits;
/* FIXME: should avoid putting x<left pixels (minor speed issue) */ /* FIXME: should avoid putting x<left pixels (minor speed issue) */
for (i = dstwidth/8, x = left; i > 0; i--) { for (i = width/8, x = left; i > 0; i--) {
srcval=*srcbyte++; srcval=*srcbyte++;
XPutPixel( bmpImage, x++, h, colors[ srcval >> 7] ); XPutPixel( bmpImage, x++, h, colors[ srcval >> 7] );
XPutPixel( bmpImage, x++, h, colors[(srcval >> 6) & 1] ); XPutPixel( bmpImage, x++, h, colors[(srcval >> 6) & 1] );
...@@ -432,9 +433,9 @@ static void X11DRV_DIB_SetImageBits_1( int lines, const BYTE *srcbits, ...@@ -432,9 +433,9 @@ static void X11DRV_DIB_SetImageBits_1( int lines, const BYTE *srcbits,
XPutPixel( bmpImage, x++, h, colors[(srcval >> 1) & 1] ); XPutPixel( bmpImage, x++, h, colors[(srcval >> 1) & 1] );
XPutPixel( bmpImage, x++, h, colors[ srcval & 1] ); XPutPixel( bmpImage, x++, h, colors[ srcval & 1] );
} }
if (dstwidth % 8){ if (width % 8){
srcval=*srcbyte; srcval=*srcbyte;
switch (dstwidth & 7) switch (width & 7)
{ {
case 7: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1; case 7: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1;
case 6: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1; case 6: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1;
...@@ -460,7 +461,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -460,7 +461,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
XImage *bmpImage, DWORD linebytes ) XImage *bmpImage, DWORD linebytes )
{ {
DWORD x; DWORD x;
int h; int h, width = min(dstwidth, srcwidth);
if (lines < 0 ) { if (lines < 0 ) {
lines = -lines; lines = -lines;
...@@ -480,7 +481,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -480,7 +481,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
BYTE dstval; BYTE dstval;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval=srccolors[XGetPixel(bmpImage, x, h)]; srcval=srccolors[XGetPixel(bmpImage, x, h)];
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -493,7 +494,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -493,7 +494,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
dstbits += linebytes; dstbits += linebytes;
...@@ -517,7 +518,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -517,7 +518,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval=srccolors[(int)*srcpixel++]; srcval=srccolors[(int)*srcpixel++];
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -530,7 +531,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -530,7 +531,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -558,7 +559,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -558,7 +559,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -574,7 +575,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -574,7 +575,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -587,7 +588,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -587,7 +588,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
BYTE srcval; BYTE srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -603,7 +604,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -603,7 +604,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -620,7 +621,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -620,7 +621,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -636,7 +637,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -636,7 +637,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -649,7 +650,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -649,7 +650,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -665,7 +666,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -665,7 +666,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -701,7 +702,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -701,7 +702,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
srcbyte=srcbits; srcbyte=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
(colors, 2, (colors, 2,
srcbyte[2], srcbyte[2],
...@@ -713,7 +714,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -713,7 +714,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -726,7 +727,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -726,7 +727,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
srcbyte=srcbits; srcbyte=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
(colors, 2, (colors, 2,
srcbyte[0], srcbyte[0],
...@@ -738,7 +739,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -738,7 +739,7 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -763,14 +764,14 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits, ...@@ -763,14 +764,14 @@ static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
BYTE dstval; BYTE dstval;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
dstval|=(XGetPixel( bmpImage, x, h) >= white) << (7 - (x&7)); dstval|=(XGetPixel( bmpImage, x, h) >= white) << (7 - (x&7));
if ((x&7)==7) { if ((x&7)==7) {
*dstbyte++=dstval; *dstbyte++=dstval;
dstval=0; dstval=0;
} }
} }
if ((dstwidth&7)!=0) { if ((width&7)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
dstbits += linebytes; dstbits += linebytes;
...@@ -789,7 +790,7 @@ static void X11DRV_DIB_SetImageBits_4( int lines, const BYTE *srcbits, ...@@ -789,7 +790,7 @@ static void X11DRV_DIB_SetImageBits_4( int lines, const BYTE *srcbits,
DWORD srcwidth, DWORD dstwidth, int left, DWORD srcwidth, DWORD dstwidth, int left,
int *colors, XImage *bmpImage, DWORD linebytes) int *colors, XImage *bmpImage, DWORD linebytes)
{ {
int h; int h, width;
const BYTE* srcbyte; const BYTE* srcbyte;
DWORD i, x; DWORD i, x;
...@@ -804,16 +805,17 @@ static void X11DRV_DIB_SetImageBits_4( int lines, const BYTE *srcbits, ...@@ -804,16 +805,17 @@ static void X11DRV_DIB_SetImageBits_4( int lines, const BYTE *srcbits,
dstwidth++; dstwidth++;
} }
srcbits += left >> 1; srcbits += left >> 1;
width = min(srcwidth, dstwidth);
/* ==== pal 4 dib -> any bmp format ==== */ /* ==== pal 4 dib -> any bmp format ==== */
for (h = lines-1; h >= 0; h--) { for (h = lines-1; h >= 0; h--) {
srcbyte=srcbits; srcbyte=srcbits;
for (i = dstwidth/2, x = left; i > 0; i--) { for (i = width/2, x = left; i > 0; i--) {
BYTE srcval=*srcbyte++; BYTE srcval=*srcbyte++;
XPutPixel( bmpImage, x++, h, colors[srcval >> 4] ); XPutPixel( bmpImage, x++, h, colors[srcval >> 4] );
XPutPixel( bmpImage, x++, h, colors[srcval & 0x0f] ); XPutPixel( bmpImage, x++, h, colors[srcval & 0x0f] );
} }
if (dstwidth & 1) if (width & 1)
XPutPixel( bmpImage, x, h, colors[*srcbyte >> 4] ); XPutPixel( bmpImage, x, h, colors[*srcbyte >> 4] );
srcbits += linebytes; srcbits += linebytes;
} }
...@@ -832,7 +834,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -832,7 +834,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
XImage *bmpImage, DWORD linebytes ) XImage *bmpImage, DWORD linebytes )
{ {
DWORD x; DWORD x;
int h; int h, width = min(srcwidth, dstwidth);
BYTE *bits; BYTE *bits;
if (lines < 0 ) if (lines < 0 )
...@@ -855,7 +857,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -855,7 +857,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
BYTE dstval; BYTE dstval;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval=srccolors[XGetPixel(bmpImage, x, h)]; srcval=srccolors[XGetPixel(bmpImage, x, h)];
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -868,7 +870,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -868,7 +870,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&1)!=0) { if ((width&1)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
dstbits += linebytes; dstbits += linebytes;
...@@ -891,7 +893,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -891,7 +893,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval = srccolors[(int)*srcpixel++]; srcval = srccolors[(int)*srcpixel++];
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -904,7 +906,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -904,7 +906,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&1)!=0) { if ((width&1)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -932,7 +934,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -932,7 +934,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -948,7 +950,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -948,7 +950,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&1)!=0) { if ((width&1)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -961,7 +963,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -961,7 +963,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -977,7 +979,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -977,7 +979,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&1)!=0) { if ((width&1)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -994,7 +996,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -994,7 +996,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -1010,7 +1012,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1010,7 +1012,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&1)!=0) { if ((width&1)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -1023,7 +1025,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1023,7 +1025,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
dstval=0; dstval=0;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
dstval|=(X11DRV_DIB_GetNearestIndex dstval|=(X11DRV_DIB_GetNearestIndex
...@@ -1039,7 +1041,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1039,7 +1041,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
dstval=0; dstval=0;
} }
} }
if ((dstwidth&1)!=0) { if ((width&1)!=0) {
*dstbyte=dstval; *dstbyte=dstval;
} }
srcbits = (char*)srcbits - bmpImage->bytes_per_line; srcbits = (char*)srcbits - bmpImage->bytes_per_line;
...@@ -1070,7 +1072,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1070,7 +1072,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcbyte=srcbits; srcbyte=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth/2; x++) { for (x=0; x<width/2; x++) {
/* Do 2 pixels at a time */ /* Do 2 pixels at a time */
*dstbyte++=(X11DRV_DIB_GetNearestIndex *dstbyte++=(X11DRV_DIB_GetNearestIndex
(colors, 16, (colors, 16,
...@@ -1084,7 +1086,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1084,7 +1086,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcbyte[3]); srcbyte[3]);
srcbyte+=6; srcbyte+=6;
} }
if (dstwidth&1) { if (width&1) {
/* And the the odd pixel */ /* And the the odd pixel */
*dstbyte++=(X11DRV_DIB_GetNearestIndex *dstbyte++=(X11DRV_DIB_GetNearestIndex
(colors, 16, (colors, 16,
...@@ -1100,7 +1102,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1100,7 +1102,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcbyte=srcbits; srcbyte=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth/2; x++) { for (x=0; x<width/2; x++) {
/* Do 2 pixels at a time */ /* Do 2 pixels at a time */
*dstbyte++=(X11DRV_DIB_GetNearestIndex *dstbyte++=(X11DRV_DIB_GetNearestIndex
(colors, 16, (colors, 16,
...@@ -1114,7 +1116,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1114,7 +1116,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcbyte[5]); srcbyte[5]);
srcbyte+=6; srcbyte+=6;
} }
if (dstwidth&1) { if (width&1) {
/* And the the odd pixel */ /* And the the odd pixel */
*dstbyte++=(X11DRV_DIB_GetNearestIndex *dstbyte++=(X11DRV_DIB_GetNearestIndex
(colors, 16, (colors, 16,
...@@ -1146,7 +1148,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1146,7 +1148,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcbyte=srcbits; srcbyte=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth/2; x++) { for (x=0; x<width/2; x++) {
/* Do 2 pixels at a time */ /* Do 2 pixels at a time */
*dstbyte++=(X11DRV_DIB_GetNearestIndex *dstbyte++=(X11DRV_DIB_GetNearestIndex
(colors, 16, (colors, 16,
...@@ -1160,7 +1162,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1160,7 +1162,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcbyte[4]); srcbyte[4]);
srcbyte+=8; srcbyte+=8;
} }
if (dstwidth&1) { if (width&1) {
/* And the the odd pixel */ /* And the the odd pixel */
*dstbyte++=(X11DRV_DIB_GetNearestIndex *dstbyte++=(X11DRV_DIB_GetNearestIndex
(colors, 16, (colors, 16,
...@@ -1176,7 +1178,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1176,7 +1178,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcbyte=srcbits; srcbyte=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth/2; x++) { for (x=0; x<width/2; x++) {
/* Do 2 pixels at a time */ /* Do 2 pixels at a time */
*dstbyte++=(X11DRV_DIB_GetNearestIndex *dstbyte++=(X11DRV_DIB_GetNearestIndex
(colors, 16, (colors, 16,
...@@ -1190,7 +1192,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1190,7 +1192,7 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
srcbyte[6]); srcbyte[6]);
srcbyte+=8; srcbyte+=8;
} }
if (dstwidth&1) { if (width&1) {
/* And the the odd pixel */ /* And the the odd pixel */
*dstbyte++=(X11DRV_DIB_GetNearestIndex *dstbyte++=(X11DRV_DIB_GetNearestIndex
(colors, 16, (colors, 16,
...@@ -1216,11 +1218,11 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1216,11 +1218,11 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
bmpImage->green_mask, bmpImage->blue_mask ); bmpImage->green_mask, bmpImage->blue_mask );
for (h=lines-1; h>=0; h--) { for (h=lines-1; h>=0; h--) {
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<(dstwidth & ~1); x+=2) { for (x=0; x<(width & ~1); x+=2) {
*dstbyte++=(X11DRV_DIB_MapColor((int*)colors, 16, XGetPixel(bmpImage, x, h), 0) << 4) | *dstbyte++=(X11DRV_DIB_MapColor((int*)colors, 16, XGetPixel(bmpImage, x, h), 0) << 4) |
X11DRV_DIB_MapColor((int*)colors, 16, XGetPixel(bmpImage, x+1, h), 0); X11DRV_DIB_MapColor((int*)colors, 16, XGetPixel(bmpImage, x+1, h), 0);
} }
if (dstwidth & 1) { if (width & 1) {
*dstbyte=(X11DRV_DIB_MapColor((int *)colors, 16, XGetPixel(bmpImage, x, h), 0) << 4); *dstbyte=(X11DRV_DIB_MapColor((int *)colors, 16, XGetPixel(bmpImage, x, h), 0) << 4);
} }
dstbits += linebytes; dstbits += linebytes;
...@@ -1236,11 +1238,11 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits, ...@@ -1236,11 +1238,11 @@ static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
* SetDIBits for a 4-bit deep compressed DIB. * SetDIBits for a 4-bit deep compressed DIB.
*/ */
static void X11DRV_DIB_SetImageBits_RLE4( int lines, const BYTE *bits, static void X11DRV_DIB_SetImageBits_RLE4( int lines, const BYTE *bits,
DWORD width, DWORD dstwidth, DWORD srcwidth, DWORD dstwidth,
int left, int *colors, int left, int *colors,
XImage *bmpImage ) XImage *bmpImage )
{ {
unsigned int x = 0; unsigned int x = 0, width = min(srcwidth, dstwidth);
int y = lines - 1, c, length; int y = lines - 1, c, length;
const BYTE *begin = bits; const BYTE *begin = bits;
...@@ -1300,7 +1302,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits, ...@@ -1300,7 +1302,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits,
DWORD linebytes ) DWORD linebytes )
{ {
DWORD x; DWORD x;
int h; int h, width = min(srcwidth, dstwidth);
const BYTE* srcbyte; const BYTE* srcbyte;
BYTE* dstbits; BYTE* dstbits;
...@@ -1318,7 +1320,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits, ...@@ -1318,7 +1320,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits,
case 16: case 16:
#if defined(__i386__) && defined(__GNUC__) #if defined(__i386__) && defined(__GNUC__)
/* Some X servers might have 32 bit/ 16bit deep pixel */ /* Some X servers might have 32 bit/ 16bit deep pixel */
if (lines && dstwidth && (bmpImage->bits_per_pixel == 16) && if (lines && width && (bmpImage->bits_per_pixel == 16) &&
(ImageByteOrder(gdi_display)==LSBFirst) ) (ImageByteOrder(gdi_display)==LSBFirst) )
{ {
dstbits=bmpImage->data+left*2+(lines-1)*bmpImage->bytes_per_line; dstbits=bmpImage->data+left*2+(lines-1)*bmpImage->bytes_per_line;
...@@ -1339,7 +1341,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits, ...@@ -1339,7 +1341,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits,
:"=S" (srcbyte), "=D" (_cl1), "=c" (_cl2) :"=S" (srcbyte), "=D" (_cl1), "=c" (_cl2)
:"S" (srcbyte), :"S" (srcbyte),
"D" (dstbits), "D" (dstbits),
"c" (dstwidth), "c" (width),
"d" (colors) "d" (colors)
:"eax", "cc", "memory" :"eax", "cc", "memory"
); );
...@@ -1353,7 +1355,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits, ...@@ -1353,7 +1355,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits,
case 24: case 24:
case 32: case 32:
#if defined(__i386__) && defined(__GNUC__) #if defined(__i386__) && defined(__GNUC__)
if (lines && dstwidth && (bmpImage->bits_per_pixel == 32) && if (lines && width && (bmpImage->bits_per_pixel == 32) &&
(ImageByteOrder(gdi_display)==LSBFirst) ) (ImageByteOrder(gdi_display)==LSBFirst) )
{ {
dstbits=bmpImage->data+left*4+(lines-1)*bmpImage->bytes_per_line; dstbits=bmpImage->data+left*4+(lines-1)*bmpImage->bytes_per_line;
...@@ -1374,7 +1376,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits, ...@@ -1374,7 +1376,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits,
:"=S" (srcbyte), "=D" (_cl1), "=c" (_cl2) :"=S" (srcbyte), "=D" (_cl1), "=c" (_cl2)
:"S" (srcbyte), :"S" (srcbyte),
"D" (dstbits), "D" (dstbits),
"c" (dstwidth), "c" (width),
"d" (colors) "d" (colors)
:"eax", "cc", "memory" :"eax", "cc", "memory"
); );
...@@ -1391,7 +1393,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits, ...@@ -1391,7 +1393,7 @@ static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits,
/* ==== pal 8 dib -> any bmp format ==== */ /* ==== pal 8 dib -> any bmp format ==== */
for (h=lines-1; h>=0; h--) { for (h=lines-1; h>=0; h--) {
for (x=left; x<dstwidth+left; x++) { for (x=left; x<width+left; x++) {
XPutPixel(bmpImage, x, h, colors[*srcbyte++]); XPutPixel(bmpImage, x, h, colors[*srcbyte++]);
} }
srcbyte = (srcbits += linebytes); srcbyte = (srcbits += linebytes);
...@@ -1409,7 +1411,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1409,7 +1411,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
XImage *bmpImage, DWORD linebytes ) XImage *bmpImage, DWORD linebytes )
{ {
DWORD x; DWORD x;
int h; int h, width = min(srcwidth, dstwidth);
BYTE* dstbyte; BYTE* dstbyte;
if (lines < 0 ) if (lines < 0 )
...@@ -1437,7 +1439,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1437,7 +1439,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
/* ==== pal 4 bmp -> pal 8 dib ==== */ /* ==== pal 4 bmp -> pal 8 dib ==== */
for (h=lines-1; h>=0; h--) { for (h=lines-1; h>=0; h--) {
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval=srccolors[XGetPixel(bmpImage, x, h)]; srcval=srccolors[XGetPixel(bmpImage, x, h)];
*dstbyte++=X11DRV_DIB_GetNearestIndex(colors, 256, *dstbyte++=X11DRV_DIB_GetNearestIndex(colors, 256,
...@@ -1462,7 +1464,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1462,7 +1464,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval=srccolors[(int)*srcpixel++]; srcval=srccolors[(int)*srcpixel++];
*dstbyte++=X11DRV_DIB_GetNearestIndex(colors, 256, *dstbyte++=X11DRV_DIB_GetNearestIndex(colors, 256,
...@@ -1493,7 +1495,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1493,7 +1495,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
*dstbyte++=X11DRV_DIB_GetNearestIndex *dstbyte++=X11DRV_DIB_GetNearestIndex
...@@ -1513,7 +1515,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1513,7 +1515,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
*dstbyte++=X11DRV_DIB_GetNearestIndex *dstbyte++=X11DRV_DIB_GetNearestIndex
...@@ -1537,7 +1539,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1537,7 +1539,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
*dstbyte++=X11DRV_DIB_GetNearestIndex *dstbyte++=X11DRV_DIB_GetNearestIndex
...@@ -1557,7 +1559,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1557,7 +1559,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
WORD srcval; WORD srcval;
srcval=*srcpixel++; srcval=*srcpixel++;
*dstbyte++=X11DRV_DIB_GetNearestIndex *dstbyte++=X11DRV_DIB_GetNearestIndex
...@@ -1600,7 +1602,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1600,7 +1602,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcbyte=srcbits; srcbyte=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
*dstbyte++=X11DRV_DIB_GetNearestIndex *dstbyte++=X11DRV_DIB_GetNearestIndex
(colors, 256, (colors, 256,
srcbyte[2], srcbyte[2],
...@@ -1616,7 +1618,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1616,7 +1618,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcbyte=srcbits; srcbyte=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
*dstbyte++=X11DRV_DIB_GetNearestIndex *dstbyte++=X11DRV_DIB_GetNearestIndex
(colors, 256, (colors, 256,
srcbyte[0], srcbyte[0],
...@@ -1640,7 +1642,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1640,7 +1642,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
/* ==== any bmp format -> pal 8 dib ==== */ /* ==== any bmp format -> pal 8 dib ==== */
for (h=lines-1; h>=0; h--) { for (h=lines-1; h>=0; h--) {
dstbyte=dstbits; dstbyte=dstbits;
for (x=0; x<dstwidth; x++) { for (x=0; x<width; x++) {
*dstbyte=X11DRV_DIB_MapColor *dstbyte=X11DRV_DIB_MapColor
((int*)colors, 256, ((int*)colors, 256,
XGetPixel(bmpImage, x, h), *dstbyte); XGetPixel(bmpImage, x, h), *dstbyte);
...@@ -1673,7 +1675,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits, ...@@ -1673,7 +1675,7 @@ static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
* [JAY] * [JAY]
*/ */
static void X11DRV_DIB_SetImageBits_RLE8( int lines, const BYTE *bits, static void X11DRV_DIB_SetImageBits_RLE8( int lines, const BYTE *bits,
DWORD width, DWORD dstwidth, DWORD srcwidth, DWORD dstwidth,
int left, int *colors, int left, int *colors,
XImage *bmpImage ) XImage *bmpImage )
{ {
...@@ -1778,7 +1780,7 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1778,7 +1780,7 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
XImage *bmpImage, DWORD linebytes ) XImage *bmpImage, DWORD linebytes )
{ {
DWORD x; DWORD x;
int h; int h, width = min(srcwidth, dstwidth);
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap; const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap;
if (lines < 0 ) if (lines < 0 )
...@@ -1804,14 +1806,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1804,14 +1806,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
/* ==== rgb 555 dib -> rgb 555 bmp ==== */ /* ==== rgb 555 dib -> rgb 555 bmp ==== */
/* ==== bgr 555 dib -> bgr 555 bmp ==== */ /* ==== bgr 555 dib -> bgr 555 bmp ==== */
convs->Convert_5x5_asis convs->Convert_5x5_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if (rSrc==bmpImage->blue_mask) { } else if (rSrc==bmpImage->blue_mask) {
/* ==== rgb 555 dib -> bgr 555 bmp ==== */ /* ==== rgb 555 dib -> bgr 555 bmp ==== */
/* ==== bgr 555 dib -> rgb 555 bmp ==== */ /* ==== bgr 555 dib -> rgb 555 bmp ==== */
convs->Convert_555_reverse convs->Convert_555_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -1820,14 +1822,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1820,14 +1822,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
/* ==== rgb 565 dib -> rgb 555 bmp ==== */ /* ==== rgb 565 dib -> rgb 555 bmp ==== */
/* ==== bgr 565 dib -> bgr 555 bmp ==== */ /* ==== bgr 565 dib -> bgr 555 bmp ==== */
convs->Convert_565_to_555_asis convs->Convert_565_to_555_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 565 dib -> bgr 555 bmp ==== */ /* ==== rgb 565 dib -> bgr 555 bmp ==== */
/* ==== bgr 565 dib -> rgb 555 bmp ==== */ /* ==== bgr 565 dib -> rgb 555 bmp ==== */
convs->Convert_565_to_555_reverse convs->Convert_565_to_555_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -1838,14 +1840,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1838,14 +1840,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
/* ==== rgb 565 dib -> rgb 565 bmp ==== */ /* ==== rgb 565 dib -> rgb 565 bmp ==== */
/* ==== bgr 565 dib -> bgr 565 bmp ==== */ /* ==== bgr 565 dib -> bgr 565 bmp ==== */
convs->Convert_5x5_asis convs->Convert_5x5_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 565 dib -> bgr 565 bmp ==== */ /* ==== rgb 565 dib -> bgr 565 bmp ==== */
/* ==== bgr 565 dib -> rgb 565 bmp ==== */ /* ==== bgr 565 dib -> rgb 565 bmp ==== */
convs->Convert_565_reverse convs->Convert_565_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -1854,14 +1856,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1854,14 +1856,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
/* ==== rgb 555 dib -> rgb 565 bmp ==== */ /* ==== rgb 555 dib -> rgb 565 bmp ==== */
/* ==== bgr 555 dib -> bgr 565 bmp ==== */ /* ==== bgr 555 dib -> bgr 565 bmp ==== */
convs->Convert_555_to_565_asis convs->Convert_555_to_565_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 555 dib -> bgr 565 bmp ==== */ /* ==== rgb 555 dib -> bgr 565 bmp ==== */
/* ==== bgr 555 dib -> rgb 565 bmp ==== */ /* ==== bgr 555 dib -> rgb 565 bmp ==== */
convs->Convert_555_to_565_reverse convs->Convert_555_to_565_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -1888,14 +1890,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1888,14 +1890,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
/* ==== rgb 555 dib -> rgb 888 bmp ==== */ /* ==== rgb 555 dib -> rgb 888 bmp ==== */
/* ==== bgr 555 dib -> bgr 888 bmp ==== */ /* ==== bgr 555 dib -> bgr 888 bmp ==== */
convs->Convert_555_to_888_asis convs->Convert_555_to_888_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 565 dib -> rgb 888 bmp ==== */ /* ==== rgb 565 dib -> rgb 888 bmp ==== */
/* ==== bgr 565 dib -> bgr 888 bmp ==== */ /* ==== bgr 565 dib -> bgr 888 bmp ==== */
convs->Convert_565_to_888_asis convs->Convert_565_to_888_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -1904,14 +1906,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1904,14 +1906,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
/* ==== rgb 555 dib -> bgr 888 bmp ==== */ /* ==== rgb 555 dib -> bgr 888 bmp ==== */
/* ==== bgr 555 dib -> rgb 888 bmp ==== */ /* ==== bgr 555 dib -> rgb 888 bmp ==== */
convs->Convert_555_to_888_reverse convs->Convert_555_to_888_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 565 dib -> bgr 888 bmp ==== */ /* ==== rgb 565 dib -> bgr 888 bmp ==== */
/* ==== bgr 565 dib -> rgb 888 bmp ==== */ /* ==== bgr 565 dib -> rgb 888 bmp ==== */
convs->Convert_565_to_888_reverse convs->Convert_565_to_888_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -1936,14 +1938,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1936,14 +1938,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
/* ==== rgb 555 dib -> rgb 0888 bmp ==== */ /* ==== rgb 555 dib -> rgb 0888 bmp ==== */
/* ==== bgr 555 dib -> bgr 0888 bmp ==== */ /* ==== bgr 555 dib -> bgr 0888 bmp ==== */
convs->Convert_555_to_0888_asis convs->Convert_555_to_0888_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 565 dib -> rgb 0888 bmp ==== */ /* ==== rgb 565 dib -> rgb 0888 bmp ==== */
/* ==== bgr 565 dib -> bgr 0888 bmp ==== */ /* ==== bgr 565 dib -> bgr 0888 bmp ==== */
convs->Convert_565_to_0888_asis convs->Convert_565_to_0888_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -1952,14 +1954,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -1952,14 +1954,14 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
/* ==== rgb 555 dib -> bgr 0888 bmp ==== */ /* ==== rgb 555 dib -> bgr 0888 bmp ==== */
/* ==== bgr 555 dib -> rgb 0888 bmp ==== */ /* ==== bgr 555 dib -> rgb 0888 bmp ==== */
convs->Convert_555_to_0888_reverse convs->Convert_555_to_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 565 dib -> bgr 0888 bmp ==== */ /* ==== rgb 565 dib -> bgr 0888 bmp ==== */
/* ==== bgr 565 dib -> rgb 0888 bmp ==== */ /* ==== bgr 565 dib -> rgb 0888 bmp ==== */
convs->Convert_565_to_0888_reverse convs->Convert_565_to_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -2009,7 +2011,7 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits, ...@@ -2009,7 +2011,7 @@ static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
*/ */
for (h=lines-1; h>=0; h--) { for (h=lines-1; h>=0; h--) {
srcpixel=(const WORD*)srcbits; srcpixel=(const WORD*)srcbits;
for (x=left; x<dstwidth+left; x++) { for (x=left; x<width+left; x++) {
DWORD srcval; DWORD srcval;
BYTE red,green,blue; BYTE red,green,blue;
srcval=*srcpixel++ << 16; srcval=*srcpixel++ << 16;
...@@ -2043,7 +2045,7 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2043,7 +2045,7 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
XImage *bmpImage, DWORD dibpitch ) XImage *bmpImage, DWORD dibpitch )
{ {
DWORD x; DWORD x;
int h; int h, width = min(srcwidth, dstwidth);
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap; const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap;
DWORD linebytes = dibpitch; DWORD linebytes = dibpitch;
...@@ -2070,14 +2072,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2070,14 +2072,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
/* ==== rgb 555 bmp -> rgb 555 dib ==== */ /* ==== rgb 555 bmp -> rgb 555 dib ==== */
/* ==== bgr 555 bmp -> bgr 555 dib ==== */ /* ==== bgr 555 bmp -> bgr 555 dib ==== */
convs->Convert_5x5_asis convs->Convert_5x5_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 555 bmp -> bgr 555 dib ==== */ /* ==== rgb 555 bmp -> bgr 555 dib ==== */
/* ==== bgr 555 bmp -> rgb 555 dib ==== */ /* ==== bgr 555 bmp -> rgb 555 dib ==== */
convs->Convert_555_reverse convs->Convert_555_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2086,14 +2088,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2086,14 +2088,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
/* ==== rgb 555 bmp -> rgb 565 dib ==== */ /* ==== rgb 555 bmp -> rgb 565 dib ==== */
/* ==== bgr 555 bmp -> bgr 565 dib ==== */ /* ==== bgr 555 bmp -> bgr 565 dib ==== */
convs->Convert_555_to_565_asis convs->Convert_555_to_565_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 555 bmp -> bgr 565 dib ==== */ /* ==== rgb 555 bmp -> bgr 565 dib ==== */
/* ==== bgr 555 bmp -> rgb 565 dib ==== */ /* ==== bgr 555 bmp -> rgb 565 dib ==== */
convs->Convert_555_to_565_reverse convs->Convert_555_to_565_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2104,14 +2106,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2104,14 +2106,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
/* ==== rgb 565 bmp -> rgb 565 dib ==== */ /* ==== rgb 565 bmp -> rgb 565 dib ==== */
/* ==== bgr 565 bmp -> bgr 565 dib ==== */ /* ==== bgr 565 bmp -> bgr 565 dib ==== */
convs->Convert_5x5_asis convs->Convert_5x5_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 565 bmp -> bgr 565 dib ==== */ /* ==== rgb 565 bmp -> bgr 565 dib ==== */
/* ==== bgr 565 bmp -> rgb 565 dib ==== */ /* ==== bgr 565 bmp -> rgb 565 dib ==== */
convs->Convert_565_reverse convs->Convert_565_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2120,14 +2122,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2120,14 +2122,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
/* ==== rgb 565 bmp -> rgb 555 dib ==== */ /* ==== rgb 565 bmp -> rgb 555 dib ==== */
/* ==== bgr 565 bmp -> bgr 555 dib ==== */ /* ==== bgr 565 bmp -> bgr 555 dib ==== */
convs->Convert_565_to_555_asis convs->Convert_565_to_555_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 565 bmp -> bgr 555 dib ==== */ /* ==== rgb 565 bmp -> bgr 555 dib ==== */
/* ==== bgr 565 bmp -> rgb 555 dib ==== */ /* ==== bgr 565 bmp -> rgb 555 dib ==== */
convs->Convert_565_to_555_reverse convs->Convert_565_to_555_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2153,14 +2155,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2153,14 +2155,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
/* ==== rgb 888 bmp -> rgb 555 dib ==== */ /* ==== rgb 888 bmp -> rgb 555 dib ==== */
/* ==== bgr 888 bmp -> bgr 555 dib ==== */ /* ==== bgr 888 bmp -> bgr 555 dib ==== */
convs->Convert_888_to_555_asis convs->Convert_888_to_555_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 888 bmp -> rgb 565 dib ==== */ /* ==== rgb 888 bmp -> rgb 565 dib ==== */
/* ==== rgb 888 bmp -> rgb 565 dib ==== */ /* ==== rgb 888 bmp -> rgb 565 dib ==== */
convs->Convert_888_to_565_asis convs->Convert_888_to_565_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2169,14 +2171,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2169,14 +2171,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
/* ==== rgb 888 bmp -> bgr 555 dib ==== */ /* ==== rgb 888 bmp -> bgr 555 dib ==== */
/* ==== bgr 888 bmp -> rgb 555 dib ==== */ /* ==== bgr 888 bmp -> rgb 555 dib ==== */
convs->Convert_888_to_555_reverse convs->Convert_888_to_555_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 888 bmp -> bgr 565 dib ==== */ /* ==== rgb 888 bmp -> bgr 565 dib ==== */
/* ==== bgr 888 bmp -> rgb 565 dib ==== */ /* ==== bgr 888 bmp -> rgb 565 dib ==== */
convs->Convert_888_to_565_reverse convs->Convert_888_to_565_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2200,14 +2202,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2200,14 +2202,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
/* ==== rgb 0888 bmp -> rgb 555 dib ==== */ /* ==== rgb 0888 bmp -> rgb 555 dib ==== */
/* ==== bgr 0888 bmp -> bgr 555 dib ==== */ /* ==== bgr 0888 bmp -> bgr 555 dib ==== */
convs->Convert_0888_to_555_asis convs->Convert_0888_to_555_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 0888 bmp -> rgb 565 dib ==== */ /* ==== rgb 0888 bmp -> rgb 565 dib ==== */
/* ==== bgr 0888 bmp -> bgr 565 dib ==== */ /* ==== bgr 0888 bmp -> bgr 565 dib ==== */
convs->Convert_0888_to_565_asis convs->Convert_0888_to_565_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2216,14 +2218,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2216,14 +2218,14 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
/* ==== rgb 0888 bmp -> bgr 555 dib ==== */ /* ==== rgb 0888 bmp -> bgr 555 dib ==== */
/* ==== bgr 0888 bmp -> rgb 555 dib ==== */ /* ==== bgr 0888 bmp -> rgb 555 dib ==== */
convs->Convert_0888_to_555_reverse convs->Convert_0888_to_555_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 0888 bmp -> bgr 565 dib ==== */ /* ==== rgb 0888 bmp -> bgr 565 dib ==== */
/* ==== bgr 0888 bmp -> rgb 565 dib ==== */ /* ==== bgr 0888 bmp -> rgb 565 dib ==== */
convs->Convert_0888_to_565_reverse convs->Convert_0888_to_565_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2254,7 +2256,7 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2254,7 +2256,7 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
bDst=bDst << 16; bDst=bDst << 16;
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
dstpixel=(LPWORD)dstbits; dstpixel=(LPWORD)dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
DWORD dstval; DWORD dstval;
srcval=srccolors[XGetPixel(bmpImage, x, h)]; srcval=srccolors[XGetPixel(bmpImage, x, h)];
...@@ -2296,7 +2298,7 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2296,7 +2298,7 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
for (h=0; h<lines; h++) { for (h=0; h<lines; h++) {
srcpixel=srcbits; srcpixel=srcbits;
dstpixel=(LPWORD)dstbits; dstpixel=(LPWORD)dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
DWORD dstval; DWORD dstval;
srcval=srccolors[(int)*srcpixel++]; srcval=srccolors[(int)*srcpixel++];
...@@ -2341,7 +2343,7 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits, ...@@ -2341,7 +2343,7 @@ static void X11DRV_DIB_GetImageBits_16( int lines, BYTE *dstbits,
bDst=bDst << 16; bDst=bDst << 16;
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
dstpixel=(LPWORD)dstbits; dstpixel=(LPWORD)dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
COLORREF srcval; COLORREF srcval;
DWORD dstval; DWORD dstval;
srcval=X11DRV_PALETTE_ToLogical(XGetPixel(bmpImage, x, h)); srcval=X11DRV_PALETTE_ToLogical(XGetPixel(bmpImage, x, h));
...@@ -2370,7 +2372,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, ...@@ -2370,7 +2372,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
XImage *bmpImage, DWORD linebytes ) XImage *bmpImage, DWORD linebytes )
{ {
DWORD x; DWORD x;
int h; int h, width = min(srcwidth, dstwidth);
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap; const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap;
if (lines < 0 ) if (lines < 0 )
...@@ -2396,14 +2398,14 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, ...@@ -2396,14 +2398,14 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
/* ==== rgb 888 dib -> rgb 888 bmp ==== */ /* ==== rgb 888 dib -> rgb 888 bmp ==== */
/* ==== bgr 888 dib -> bgr 888 bmp ==== */ /* ==== bgr 888 dib -> bgr 888 bmp ==== */
convs->Convert_888_asis convs->Convert_888_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 888 dib -> bgr 888 bmp ==== */ /* ==== rgb 888 dib -> bgr 888 bmp ==== */
/* ==== bgr 888 dib -> rgb 888 bmp ==== */ /* ==== bgr 888 dib -> rgb 888 bmp ==== */
convs->Convert_888_reverse convs->Convert_888_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -2425,14 +2427,14 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, ...@@ -2425,14 +2427,14 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
/* ==== rgb 888 dib -> rgb 0888 bmp ==== */ /* ==== rgb 888 dib -> rgb 0888 bmp ==== */
/* ==== bgr 888 dib -> bgr 0888 bmp ==== */ /* ==== bgr 888 dib -> bgr 0888 bmp ==== */
convs->Convert_888_to_0888_asis convs->Convert_888_to_0888_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== rgb 888 dib -> bgr 0888 bmp ==== */ /* ==== rgb 888 dib -> bgr 0888 bmp ==== */
/* ==== bgr 888 dib -> rgb 0888 bmp ==== */ /* ==== bgr 888 dib -> rgb 0888 bmp ==== */
convs->Convert_888_to_0888_reverse convs->Convert_888_to_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} }
...@@ -2453,7 +2455,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, ...@@ -2453,7 +2455,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
/* ==== rgb 888 dib -> rgb 555 bmp ==== */ /* ==== rgb 888 dib -> rgb 555 bmp ==== */
/* ==== bgr 888 dib -> bgr 555 bmp ==== */ /* ==== bgr 888 dib -> bgr 555 bmp ==== */
convs->Convert_888_to_555_asis convs->Convert_888_to_555_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if ((rSrc==0xff && bmpImage->red_mask==0x7f00) || } else if ((rSrc==0xff && bmpImage->red_mask==0x7f00) ||
...@@ -2461,7 +2463,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, ...@@ -2461,7 +2463,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
/* ==== rgb 888 dib -> bgr 555 bmp ==== */ /* ==== rgb 888 dib -> bgr 555 bmp ==== */
/* ==== bgr 888 dib -> rgb 555 bmp ==== */ /* ==== bgr 888 dib -> rgb 555 bmp ==== */
convs->Convert_888_to_555_reverse convs->Convert_888_to_555_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
...@@ -2473,7 +2475,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, ...@@ -2473,7 +2475,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
/* ==== rgb 888 dib -> rgb 565 bmp ==== */ /* ==== rgb 888 dib -> rgb 565 bmp ==== */
/* ==== bgr 888 dib -> bgr 565 bmp ==== */ /* ==== bgr 888 dib -> bgr 565 bmp ==== */
convs->Convert_888_to_565_asis convs->Convert_888_to_565_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if ((rSrc==0xff && bmpImage->red_mask==0xf800) || } else if ((rSrc==0xff && bmpImage->red_mask==0xf800) ||
...@@ -2481,7 +2483,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, ...@@ -2481,7 +2483,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
/* ==== rgb 888 dib -> bgr 565 bmp ==== */ /* ==== rgb 888 dib -> bgr 565 bmp ==== */
/* ==== bgr 888 dib -> rgb 565 bmp ==== */ /* ==== bgr 888 dib -> rgb 565 bmp ==== */
convs->Convert_888_to_565_reverse convs->Convert_888_to_565_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
...@@ -2510,7 +2512,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits, ...@@ -2510,7 +2512,7 @@ static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
srcbits+=left*3; srcbits+=left*3;
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
srcbyte=(const BYTE*)srcbits; srcbyte=(const BYTE*)srcbits;
for (x = left; x < dstwidth+left; x++) { for (x = left; x < width+left; x++) {
XPutPixel(bmpImage, x, h, XPutPixel(bmpImage, x, h,
X11DRV_PALETTE_ToPhysical X11DRV_PALETTE_ToPhysical
(physDev, RGB(srcbyte[2], srcbyte[1], srcbyte[0]))); (physDev, RGB(srcbyte[2], srcbyte[1], srcbyte[0])));
...@@ -2536,7 +2538,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2536,7 +2538,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
XImage *bmpImage, DWORD linebytes ) XImage *bmpImage, DWORD linebytes )
{ {
DWORD x; DWORD x;
int h; int h, width = min(srcwidth, dstwidth);
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap; const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap;
if (lines < 0 ) if (lines < 0 )
...@@ -2561,14 +2563,14 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2561,14 +2563,14 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
/* ==== rgb 888 bmp -> rgb 888 dib ==== */ /* ==== rgb 888 bmp -> rgb 888 dib ==== */
/* ==== bgr 888 bmp -> bgr 888 dib ==== */ /* ==== bgr 888 bmp -> bgr 888 dib ==== */
convs->Convert_888_asis convs->Convert_888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 888 bmp -> bgr 888 dib ==== */ /* ==== rgb 888 bmp -> bgr 888 dib ==== */
/* ==== bgr 888 bmp -> rgb 888 dib ==== */ /* ==== bgr 888 bmp -> rgb 888 dib ==== */
convs->Convert_888_reverse convs->Convert_888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2589,14 +2591,14 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2589,14 +2591,14 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
/* ==== rgb 888 bmp -> rgb 0888 dib ==== */ /* ==== rgb 888 bmp -> rgb 0888 dib ==== */
/* ==== bgr 888 bmp -> bgr 0888 dib ==== */ /* ==== bgr 888 bmp -> bgr 0888 dib ==== */
convs->Convert_0888_to_888_asis convs->Convert_0888_to_888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== rgb 888 bmp -> bgr 0888 dib ==== */ /* ==== rgb 888 bmp -> bgr 0888 dib ==== */
/* ==== bgr 888 bmp -> rgb 0888 dib ==== */ /* ==== bgr 888 bmp -> rgb 0888 dib ==== */
convs->Convert_0888_to_888_reverse convs->Convert_0888_to_888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} }
...@@ -2616,7 +2618,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2616,7 +2618,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
/* ==== rgb 555 bmp -> rgb 888 dib ==== */ /* ==== rgb 555 bmp -> rgb 888 dib ==== */
/* ==== bgr 555 bmp -> bgr 888 dib ==== */ /* ==== bgr 555 bmp -> bgr 888 dib ==== */
convs->Convert_555_to_888_asis convs->Convert_555_to_888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if ((rDst==0xff && bmpImage->red_mask==0x7f00) || } else if ((rDst==0xff && bmpImage->red_mask==0x7f00) ||
...@@ -2624,7 +2626,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2624,7 +2626,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
/* ==== rgb 555 bmp -> bgr 888 dib ==== */ /* ==== rgb 555 bmp -> bgr 888 dib ==== */
/* ==== bgr 555 bmp -> rgb 888 dib ==== */ /* ==== bgr 555 bmp -> rgb 888 dib ==== */
convs->Convert_555_to_888_reverse convs->Convert_555_to_888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
...@@ -2636,7 +2638,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2636,7 +2638,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
/* ==== rgb 565 bmp -> rgb 888 dib ==== */ /* ==== rgb 565 bmp -> rgb 888 dib ==== */
/* ==== bgr 565 bmp -> bgr 888 dib ==== */ /* ==== bgr 565 bmp -> bgr 888 dib ==== */
convs->Convert_565_to_888_asis convs->Convert_565_to_888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if ((rDst==0xff && bmpImage->red_mask==0xf800) || } else if ((rDst==0xff && bmpImage->red_mask==0xf800) ||
...@@ -2644,7 +2646,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2644,7 +2646,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
/* ==== rgb 565 bmp -> bgr 888 dib ==== */ /* ==== rgb 565 bmp -> bgr 888 dib ==== */
/* ==== bgr 565 bmp -> rgb 888 dib ==== */ /* ==== bgr 565 bmp -> rgb 888 dib ==== */
convs->Convert_565_to_888_reverse convs->Convert_565_to_888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
...@@ -2665,7 +2667,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2665,7 +2667,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
/* Windows only supports one 24bpp DIB format: rgb 888 */ /* Windows only supports one 24bpp DIB format: rgb 888 */
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
dstbyte=dstbits; dstbyte=dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval=srccolors[XGetPixel(bmpImage, x, h)]; srcval=srccolors[XGetPixel(bmpImage, x, h)];
dstbyte[0]=srcval.peBlue; dstbyte[0]=srcval.peBlue;
...@@ -2692,7 +2694,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2692,7 +2694,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
srcpixel=srcbits; srcpixel=srcbits;
dstbyte=dstbits; dstbyte=dstbits;
for (x = 0; x < dstwidth; x++ ) { for (x = 0; x < width; x++ ) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval=srccolors[(int)*srcpixel++]; srcval=srccolors[(int)*srcpixel++];
dstbyte[0]=srcval.peBlue; dstbyte[0]=srcval.peBlue;
...@@ -2722,7 +2724,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits, ...@@ -2722,7 +2724,7 @@ static void X11DRV_DIB_GetImageBits_24( int lines, BYTE *dstbits,
/* Windows only supports one 24bpp DIB format: rgb 888 */ /* Windows only supports one 24bpp DIB format: rgb 888 */
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
dstbyte=dstbits; dstbyte=dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
COLORREF srcval=X11DRV_PALETTE_ToLogical COLORREF srcval=X11DRV_PALETTE_ToLogical
(XGetPixel( bmpImage, x, h )); (XGetPixel( bmpImage, x, h ));
dstbyte[0]=GetBValue(srcval); dstbyte[0]=GetBValue(srcval);
...@@ -2751,7 +2753,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2751,7 +2753,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
DWORD linebytes) DWORD linebytes)
{ {
DWORD x, *ptr; DWORD x, *ptr;
int h; int h, width = min(srcwidth, dstwidth);
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap; const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap;
if (lines < 0 ) if (lines < 0 )
...@@ -2776,7 +2778,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2776,7 +2778,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
/* ==== rgb 0888 dib -> rgb 888 bmp ==== */ /* ==== rgb 0888 dib -> rgb 888 bmp ==== */
/* ==== bgr 0888 dib -> bgr 888 bmp ==== */ /* ==== bgr 0888 dib -> bgr 888 bmp ==== */
convs->Convert_0888_to_888_asis convs->Convert_0888_to_888_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if (bmpImage->green_mask!=0x00ff00 || } else if (bmpImage->green_mask!=0x00ff00 ||
...@@ -2787,20 +2789,20 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2787,20 +2789,20 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
/* ==== rgb 0888 dib -> bgr 888 bmp ==== */ /* ==== rgb 0888 dib -> bgr 888 bmp ==== */
/* ==== bgr 0888 dib -> rgb 888 bmp ==== */ /* ==== bgr 0888 dib -> rgb 888 bmp ==== */
convs->Convert_0888_to_888_reverse convs->Convert_0888_to_888_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if (bmpImage->blue_mask==0xff) { } else if (bmpImage->blue_mask==0xff) {
/* ==== any 0888 dib -> rgb 888 bmp ==== */ /* ==== any 0888 dib -> rgb 888 bmp ==== */
convs->Convert_any0888_to_rgb888 convs->Convert_any0888_to_rgb888
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
rSrc,gSrc,bSrc, rSrc,gSrc,bSrc,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== any 0888 dib -> bgr 888 bmp ==== */ /* ==== any 0888 dib -> bgr 888 bmp ==== */
convs->Convert_any0888_to_bgr888 convs->Convert_any0888_to_bgr888
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
rSrc,gSrc,bSrc, rSrc,gSrc,bSrc,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
...@@ -2821,7 +2823,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2821,7 +2823,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
/* ==== rgb 0888 dib -> rgb 0888 bmp ==== */ /* ==== rgb 0888 dib -> rgb 0888 bmp ==== */
/* ==== bgr 0888 dib -> bgr 0888 bmp ==== */ /* ==== bgr 0888 dib -> bgr 0888 bmp ==== */
convs->Convert_0888_asis convs->Convert_0888_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if (bmpImage->green_mask!=0x00ff00 || } else if (bmpImage->green_mask!=0x00ff00 ||
...@@ -2832,13 +2834,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2832,13 +2834,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
/* ==== rgb 0888 dib -> bgr 0888 bmp ==== */ /* ==== rgb 0888 dib -> bgr 0888 bmp ==== */
/* ==== bgr 0888 dib -> rgb 0888 bmp ==== */ /* ==== bgr 0888 dib -> rgb 0888 bmp ==== */
convs->Convert_0888_reverse convs->Convert_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
/* ==== any 0888 dib -> any 0888 bmp ==== */ /* ==== any 0888 dib -> any 0888 bmp ==== */
convs->Convert_0888_any convs->Convert_0888_any
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
rSrc,gSrc,bSrc, rSrc,gSrc,bSrc,
dstbits,-bmpImage->bytes_per_line, dstbits,-bmpImage->bytes_per_line,
...@@ -2851,7 +2853,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2851,7 +2853,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
} else { } else {
/* ==== any 0888 dib -> any 0888 bmp ==== */ /* ==== any 0888 dib -> any 0888 bmp ==== */
convs->Convert_0888_any convs->Convert_0888_any
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
rSrc,gSrc,bSrc, rSrc,gSrc,bSrc,
dstbits,-bmpImage->bytes_per_line, dstbits,-bmpImage->bytes_per_line,
...@@ -2873,13 +2875,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2873,13 +2875,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
if (bmpImage->red_mask==0x7f00) { if (bmpImage->red_mask==0x7f00) {
/* ==== rgb 0888 dib -> rgb 555 bmp ==== */ /* ==== rgb 0888 dib -> rgb 555 bmp ==== */
convs->Convert_0888_to_555_asis convs->Convert_0888_to_555_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if (bmpImage->blue_mask==0x7f00) { } else if (bmpImage->blue_mask==0x7f00) {
/* ==== rgb 0888 dib -> bgr 555 bmp ==== */ /* ==== rgb 0888 dib -> bgr 555 bmp ==== */
convs->Convert_0888_to_555_reverse convs->Convert_0888_to_555_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
...@@ -2889,13 +2891,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2889,13 +2891,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
if (bmpImage->red_mask==0xf800) { if (bmpImage->red_mask==0xf800) {
/* ==== rgb 0888 dib -> rgb 565 bmp ==== */ /* ==== rgb 0888 dib -> rgb 565 bmp ==== */
convs->Convert_0888_to_565_asis convs->Convert_0888_to_565_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if (bmpImage->blue_mask==0xf800) { } else if (bmpImage->blue_mask==0xf800) {
/* ==== rgb 0888 dib -> bgr 565 bmp ==== */ /* ==== rgb 0888 dib -> bgr 565 bmp ==== */
convs->Convert_0888_to_565_reverse convs->Convert_0888_to_565_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
...@@ -2909,13 +2911,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2909,13 +2911,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
if (bmpImage->blue_mask==0x7f00) { if (bmpImage->blue_mask==0x7f00) {
/* ==== bgr 0888 dib -> bgr 555 bmp ==== */ /* ==== bgr 0888 dib -> bgr 555 bmp ==== */
convs->Convert_0888_to_555_asis convs->Convert_0888_to_555_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if (bmpImage->red_mask==0x7f00) { } else if (bmpImage->red_mask==0x7f00) {
/* ==== bgr 0888 dib -> rgb 555 bmp ==== */ /* ==== bgr 0888 dib -> rgb 555 bmp ==== */
convs->Convert_0888_to_555_reverse convs->Convert_0888_to_555_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
...@@ -2925,13 +2927,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2925,13 +2927,13 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
if (bmpImage->blue_mask==0xf800) { if (bmpImage->blue_mask==0xf800) {
/* ==== bgr 0888 dib -> bgr 565 bmp ==== */ /* ==== bgr 0888 dib -> bgr 565 bmp ==== */
convs->Convert_0888_to_565_asis convs->Convert_0888_to_565_asis
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else if (bmpImage->red_mask==0xf800) { } else if (bmpImage->red_mask==0xf800) {
/* ==== bgr 0888 dib -> rgb 565 bmp ==== */ /* ==== bgr 0888 dib -> rgb 565 bmp ==== */
convs->Convert_0888_to_565_reverse convs->Convert_0888_to_565_reverse
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
dstbits,-bmpImage->bytes_per_line); dstbits,-bmpImage->bytes_per_line);
} else { } else {
...@@ -2946,7 +2948,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2946,7 +2948,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
bmpImage->blue_mask==0x7f00)) { bmpImage->blue_mask==0x7f00)) {
/* ==== any 0888 dib -> rgb or bgr 555 bmp ==== */ /* ==== any 0888 dib -> rgb or bgr 555 bmp ==== */
convs->Convert_any0888_to_5x5 convs->Convert_any0888_to_5x5
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
rSrc,gSrc,bSrc, rSrc,gSrc,bSrc,
dstbits,-bmpImage->bytes_per_line, dstbits,-bmpImage->bytes_per_line,
...@@ -2956,7 +2958,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2956,7 +2958,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
bmpImage->blue_mask==0xf800)) { bmpImage->blue_mask==0xf800)) {
/* ==== any 0888 dib -> rgb or bgr 565 bmp ==== */ /* ==== any 0888 dib -> rgb or bgr 565 bmp ==== */
convs->Convert_any0888_to_5x5 convs->Convert_any0888_to_5x5
(dstwidth,lines, (width,lines,
srcbits,linebytes, srcbits,linebytes,
rSrc,gSrc,bSrc, rSrc,gSrc,bSrc,
dstbits,-bmpImage->bytes_per_line, dstbits,-bmpImage->bytes_per_line,
...@@ -2988,7 +2990,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits, ...@@ -2988,7 +2990,7 @@ static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
srcbits+=left*4; srcbits+=left*4;
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
srcpixel=(const DWORD*)srcbits; srcpixel=(const DWORD*)srcbits;
for (x = left; x < dstwidth+left; x++) { for (x = left; x < width+left; x++) {
DWORD srcvalue; DWORD srcvalue;
BYTE red,green,blue; BYTE red,green,blue;
srcvalue=*srcpixel++; srcvalue=*srcpixel++;
...@@ -3018,7 +3020,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3018,7 +3020,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
XImage *bmpImage, DWORD linebytes ) XImage *bmpImage, DWORD linebytes )
{ {
DWORD x; DWORD x;
int h; int h, width = min(srcwidth, dstwidth);
BYTE *bits; BYTE *bits;
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap; const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap;
...@@ -3043,7 +3045,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3043,7 +3045,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
/* ==== rgb 888 bmp -> rgb 0888 dib ==== */ /* ==== rgb 888 bmp -> rgb 0888 dib ==== */
/* ==== bgr 888 bmp -> bgr 0888 dib ==== */ /* ==== bgr 888 bmp -> bgr 0888 dib ==== */
convs->Convert_888_to_0888_asis convs->Convert_888_to_0888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if (bmpImage->green_mask!=0x00ff00 || } else if (bmpImage->green_mask!=0x00ff00 ||
...@@ -3054,20 +3056,20 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3054,20 +3056,20 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
/* ==== rgb 888 bmp -> bgr 0888 dib ==== */ /* ==== rgb 888 bmp -> bgr 0888 dib ==== */
/* ==== bgr 888 bmp -> rgb 0888 dib ==== */ /* ==== bgr 888 bmp -> rgb 0888 dib ==== */
convs->Convert_888_to_0888_reverse convs->Convert_888_to_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if (bmpImage->blue_mask==0xff) { } else if (bmpImage->blue_mask==0xff) {
/* ==== rgb 888 bmp -> any 0888 dib ==== */ /* ==== rgb 888 bmp -> any 0888 dib ==== */
convs->Convert_rgb888_to_any0888 convs->Convert_rgb888_to_any0888
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes, dstbits,linebytes,
rDst,gDst,bDst); rDst,gDst,bDst);
} else { } else {
/* ==== bgr 888 bmp -> any 0888 dib ==== */ /* ==== bgr 888 bmp -> any 0888 dib ==== */
convs->Convert_bgr888_to_any0888 convs->Convert_bgr888_to_any0888
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes, dstbits,linebytes,
rDst,gDst,bDst); rDst,gDst,bDst);
...@@ -3087,7 +3089,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3087,7 +3089,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
/* ==== rgb 0888 bmp -> rgb 0888 dib ==== */ /* ==== rgb 0888 bmp -> rgb 0888 dib ==== */
/* ==== bgr 0888 bmp -> bgr 0888 dib ==== */ /* ==== bgr 0888 bmp -> bgr 0888 dib ==== */
convs->Convert_0888_asis convs->Convert_0888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if (bmpImage->green_mask!=0x00ff00 || } else if (bmpImage->green_mask!=0x00ff00 ||
...@@ -3098,13 +3100,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3098,13 +3100,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
/* ==== rgb 0888 bmp -> bgr 0888 dib ==== */ /* ==== rgb 0888 bmp -> bgr 0888 dib ==== */
/* ==== bgr 0888 bmp -> rgb 0888 dib ==== */ /* ==== bgr 0888 bmp -> rgb 0888 dib ==== */
convs->Convert_0888_reverse convs->Convert_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
/* ==== any 0888 bmp -> any 0888 dib ==== */ /* ==== any 0888 bmp -> any 0888 dib ==== */
convs->Convert_0888_any convs->Convert_0888_any
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask, bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask,
dstbits,linebytes, dstbits,linebytes,
...@@ -3117,7 +3119,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3117,7 +3119,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
} else { } else {
/* ==== any 0888 bmp -> any 0888 dib ==== */ /* ==== any 0888 bmp -> any 0888 dib ==== */
convs->Convert_0888_any convs->Convert_0888_any
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask, bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask,
dstbits,linebytes, dstbits,linebytes,
...@@ -3138,13 +3140,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3138,13 +3140,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
if (bmpImage->red_mask==0x7f00) { if (bmpImage->red_mask==0x7f00) {
/* ==== rgb 555 bmp -> rgb 0888 dib ==== */ /* ==== rgb 555 bmp -> rgb 0888 dib ==== */
convs->Convert_555_to_0888_asis convs->Convert_555_to_0888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if (bmpImage->blue_mask==0x7f00) { } else if (bmpImage->blue_mask==0x7f00) {
/* ==== bgr 555 bmp -> rgb 0888 dib ==== */ /* ==== bgr 555 bmp -> rgb 0888 dib ==== */
convs->Convert_555_to_0888_reverse convs->Convert_555_to_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
...@@ -3154,13 +3156,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3154,13 +3156,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
if (bmpImage->red_mask==0xf800) { if (bmpImage->red_mask==0xf800) {
/* ==== rgb 565 bmp -> rgb 0888 dib ==== */ /* ==== rgb 565 bmp -> rgb 0888 dib ==== */
convs->Convert_565_to_0888_asis convs->Convert_565_to_0888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if (bmpImage->blue_mask==0xf800) { } else if (bmpImage->blue_mask==0xf800) {
/* ==== bgr 565 bmp -> rgb 0888 dib ==== */ /* ==== bgr 565 bmp -> rgb 0888 dib ==== */
convs->Convert_565_to_0888_reverse convs->Convert_565_to_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
...@@ -3174,13 +3176,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3174,13 +3176,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
if (bmpImage->blue_mask==0x7f00) { if (bmpImage->blue_mask==0x7f00) {
/* ==== bgr 555 bmp -> bgr 0888 dib ==== */ /* ==== bgr 555 bmp -> bgr 0888 dib ==== */
convs->Convert_555_to_0888_asis convs->Convert_555_to_0888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if (bmpImage->red_mask==0x7f00) { } else if (bmpImage->red_mask==0x7f00) {
/* ==== rgb 555 bmp -> bgr 0888 dib ==== */ /* ==== rgb 555 bmp -> bgr 0888 dib ==== */
convs->Convert_555_to_0888_reverse convs->Convert_555_to_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
...@@ -3190,13 +3192,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3190,13 +3192,13 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
if (bmpImage->blue_mask==0xf800) { if (bmpImage->blue_mask==0xf800) {
/* ==== bgr 565 bmp -> bgr 0888 dib ==== */ /* ==== bgr 565 bmp -> bgr 0888 dib ==== */
convs->Convert_565_to_0888_asis convs->Convert_565_to_0888_asis
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else if (bmpImage->red_mask==0xf800) { } else if (bmpImage->red_mask==0xf800) {
/* ==== rgb 565 bmp -> bgr 0888 dib ==== */ /* ==== rgb 565 bmp -> bgr 0888 dib ==== */
convs->Convert_565_to_0888_reverse convs->Convert_565_to_0888_reverse
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
dstbits,linebytes); dstbits,linebytes);
} else { } else {
...@@ -3211,7 +3213,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3211,7 +3213,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
bmpImage->blue_mask==0x7f00)) { bmpImage->blue_mask==0x7f00)) {
/* ==== rgb or bgr 555 bmp -> any 0888 dib ==== */ /* ==== rgb or bgr 555 bmp -> any 0888 dib ==== */
convs->Convert_5x5_to_any0888 convs->Convert_5x5_to_any0888
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask, bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask,
dstbits,linebytes, dstbits,linebytes,
...@@ -3221,7 +3223,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3221,7 +3223,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
bmpImage->blue_mask==0xf800)) { bmpImage->blue_mask==0xf800)) {
/* ==== rgb or bgr 565 bmp -> any 0888 dib ==== */ /* ==== rgb or bgr 565 bmp -> any 0888 dib ==== */
convs->Convert_5x5_to_any0888 convs->Convert_5x5_to_any0888
(dstwidth,lines, (width,lines,
srcbits,-bmpImage->bytes_per_line, srcbits,-bmpImage->bytes_per_line,
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask, bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask,
dstbits,linebytes, dstbits,linebytes,
...@@ -3245,7 +3247,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3245,7 +3247,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
bShift=X11DRV_DIB_MaskToShift(bDst); bShift=X11DRV_DIB_MaskToShift(bDst);
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
dstpixel=(DWORD*)dstbits; dstpixel=(DWORD*)dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval = srccolors[XGetPixel(bmpImage, x, h)]; srcval = srccolors[XGetPixel(bmpImage, x, h)];
*dstpixel++=(srcval.peRed << rShift) | *dstpixel++=(srcval.peRed << rShift) |
...@@ -3274,7 +3276,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3274,7 +3276,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
srcpixel=srcbits; srcpixel=srcbits;
dstpixel=(DWORD*)dstbits; dstpixel=(DWORD*)dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
PALETTEENTRY srcval; PALETTEENTRY srcval;
srcval=srccolors[(int)*srcpixel++]; srcval=srccolors[(int)*srcpixel++];
*dstpixel++=(srcval.peRed << rShift) | *dstpixel++=(srcval.peRed << rShift) |
...@@ -3306,7 +3308,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits, ...@@ -3306,7 +3308,7 @@ static void X11DRV_DIB_GetImageBits_32( int lines, BYTE *dstbits,
bShift=X11DRV_DIB_MaskToShift(bDst); bShift=X11DRV_DIB_MaskToShift(bDst);
for (h = lines - 1; h >= 0; h--) { for (h = lines - 1; h >= 0; h--) {
dstpixel=(DWORD*)dstbits; dstpixel=(DWORD*)dstbits;
for (x = 0; x < dstwidth; x++) { for (x = 0; x < width; x++) {
COLORREF srcval; COLORREF srcval;
srcval=X11DRV_PALETTE_ToLogical(XGetPixel(bmpImage, x, h)); srcval=X11DRV_PALETTE_ToLogical(XGetPixel(bmpImage, x, h));
*dstpixel++=(GetRValue(srcval) << rShift) | *dstpixel++=(GetRValue(srcval) << rShift) |
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment