Hi all,
again I go here to ask what is wrong with my patch sent on 23 Nov 2005 to
wine-patches (still not in CVS).
The problem with monochrome bitmaps with inverted colors was discovered in
game "Neighbours from Hell". I tested the patch with simulated inverted
colors monochrome bitmap and it is working perfectly. Also the game is
working fully. I do not see any reason why it was (probably) ignored again
(last time there was a hidden compile problem).
Find attached patch.
Regards,
Oldrich.
Index: dlls/x11drv/dib.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/dib.c,v
retrieving revision 1.45
diff -u -r1.45 dib.c
--- dlls/x11drv/dib.c 22 Sep 2005 10:44:40 -0000 1.45
+++ dlls/x11drv/dib.c 23 Nov 2005 10:45:38 -0000
@@ -521,6 +521,18 @@
}
/***********************************************************************
+ * X11DRV_DIB_CheckMask
+ *
+ * Check RGB mask if it is either 0 or matches visual's mask.
+ */
+static inline int X11DRV_DIB_CheckMask(int red_mask, int green_mask, int blue_mask)
+{
+ return ( red_mask == 0 && green_mask == 0 && blue_mask == 0 ) ||
+ ( red_mask == visual->red_mask && green_mask == visual->green_mask &&
+ blue_mask == visual->blue_mask );
+}
+
+/***********************************************************************
* X11DRV_DIB_SetImageBits_1
*
* SetDIBits for a 1-bit deep DIB.
@@ -602,7 +614,8 @@
{
case 1:
case 4:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 1 or 4 bmp -> pal 1 dib ==== */
BYTE* dstbyte;
@@ -634,7 +647,8 @@
break;
case 8:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask, bmpImage->green_mask, bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 8 bmp -> pal 1 dib ==== */
const void* srcbits;
const BYTE* srcpixel;
@@ -882,19 +896,30 @@
notsupported:
{
BYTE* dstbyte;
+ BYTE neg = 0;
unsigned long white = (1 << bmpImage->bits_per_pixel) - 1;
/* ==== any bmp format -> pal 1 dib ==== */
- WARN("from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB\n",
+ if ((unsigned)colors[0].rgbRed+colors[0].rgbGreen+
+ colors[0].rgbBlue >=
+ (unsigned)colors[1].rgbRed+colors[1].rgbGreen+
+ colors[1].rgbBlue ) {
+ neg = 1;
+ }
+
+ WARN("from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB, "
+ "%s color mapping\n",
bmpImage->bits_per_pixel, bmpImage->red_mask,
- bmpImage->green_mask, bmpImage->blue_mask );
+ bmpImage->green_mask, bmpImage->blue_mask,
+ neg?"negative":"direct" );
for (h=lines-1; h>=0; h--) {
BYTE dstval;
dstbyte=dstbits;
dstval=0;
for (x=0; x<width; x++) {
- dstval|=(XGetPixel( bmpImage, x, h) >= white) << (7 - (x&7));
+ dstval|=((XGetPixel( bmpImage, x, h) >= white) ^ neg) <<
+ (7 - (x&7));
if ((x&7)==7) {
*dstbyte++=dstval;
dstval=0;
@@ -978,7 +1003,8 @@
switch (bmpImage->depth) {
case 1:
case 4:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 1 or 4 bmp -> pal 4 dib ==== */
BYTE* dstbyte;
@@ -1010,7 +1036,8 @@
break;
case 8:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 8 bmp -> pal 4 dib ==== */
const void* srcbits;
const BYTE *srcpixel;
@@ -1568,7 +1595,8 @@
switch (bmpImage->depth) {
case 1:
case 4:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 1 bmp -> pal 8 dib ==== */
/* ==== pal 4 bmp -> pal 8 dib ==== */
@@ -1590,7 +1618,8 @@
break;
case 8:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 8 bmp -> pal 8 dib ==== */
const void* srcbits;
const BYTE* srcpixel;
@@ -2374,7 +2403,8 @@
case 1:
case 4:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 1 or 4 bmp -> rgb or bgr 555 or 565 dib ==== */
int rShift,gShift,bShift;
WORD* dstpixel;
@@ -2412,7 +2442,8 @@
break;
case 8:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 8 bmp -> rgb or bgr 555 or 565 dib ==== */
int rShift,gShift,bShift;
const BYTE* srcbits;
@@ -2799,7 +2830,8 @@
case 1:
case 4:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 1 or 4 bmp -> rgb 888 dib ==== */
BYTE* dstbyte;
@@ -2822,7 +2854,8 @@
break;
case 8:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask == 0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 8 bmp -> rgb 888 dib ==== */
const void* srcbits;
const BYTE* srcpixel;
@@ -3377,7 +3410,8 @@
case 1:
case 4:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 1 or 4 bmp -> any 0888 dib ==== */
int rShift,gShift,bShift;
DWORD* dstpixel;
@@ -3402,7 +3436,8 @@
break;
case 8:
- if (bmpImage->red_mask==0 && bmpImage->green_mask==0 && bmpImage->blue_mask==0 && srccolors) {
+ if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
+ && srccolors) {
/* ==== pal 8 bmp -> any 0888 dib ==== */
int rShift,gShift,bShift;
const void* srcbits;
@@ -4145,7 +4180,14 @@
descr.compression = dibSection.dsBmih.biCompression;
if(descr.infoBpp == 1)
- descr.colorMap = (void*)identity;
+ {
+ /* color map for monochrome bitmaps */
+ if(descr.colorMap == NULL || (descr.colorMap != NULL
+ && ((int *)descr.colorMap)[0] == ((int *)descr.colorMap)[1]))
+ {
+ descr.colorMap = (void*)identity;
+ }
+ }
switch (descr.infoBpp)
{