Re: Bug in monochrome bitmaps

2005-11-23 Thread Oldrich Jedlicka
Good, submitting to wine-patches.

Thanks :-)

Dne Wednesday 23 of November 2005 13:52 Willie Sippel napsal(a):
> Am Mittwoch, 23. November 2005 12:08 schrieb Oldrich Jedlicka:
> > Hi,
> >
> > > See:
> > > dib.c: In function 'X11DRV_DIB_DoCopyDIBSection':
> > > dib.c:4186: error: invalid operands to binary ==
> > > make[2]: *** [dib.o] Error 1
> >
> > just to be sure it compiles also on gcc 4. Here is the corrected patch.
>
> Works... :-)




Re: Bug in monochrome bitmaps

2005-11-23 Thread Willie Sippel
Am Mittwoch, 23. November 2005 12:08 schrieb Oldrich Jedlicka:
> Hi,
>
> > See:
> > dib.c: In function 'X11DRV_DIB_DoCopyDIBSection':
> > dib.c:4186: error: invalid operands to binary ==
> > make[2]: *** [dib.o] Error 1
>
> just to be sure it compiles also on gcc 4. Here is the corrected patch.
>
Works... :-)

-- 
Willie Sippel

    |  Tritium Studios
 // |  __
 ///|  http://www.tritium-studios.com

<[EMAIL PROTECTED]>




Re: Bug in monochrome bitmaps

2005-11-23 Thread Oldrich Jedlicka
Hi,

> See:
> dib.c: In function 'X11DRV_DIB_DoCopyDIBSection':
> dib.c:4186: error: invalid operands to binary ==
> make[2]: *** [dib.o] Error 1

just to be sure it compiles also on gcc 4. Here is the corrected patch.

Cheers,

  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 -	1.45
+++ dlls/x11drv/dib.c	23 Nov 2005 10:45:38 -
@@ -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= 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

Re: Bug in monochrome bitmaps

2005-11-23 Thread Oldrich Jedlicka
Thanks Willie,

ok, that's it. I didn't try to compile it after I sent the patch first time 
(it was working for me). I will fix it and resend a patch to wine-patches.

Cheers,

  Oldrich.

Dne Wednesday 23 of November 2005 10:35 Willie Sippel napsal(a):
> Am Mittwoch, 23. November 2005 09:41 schrieb Oldrich Jedlicka:
> > Hi all,
> >
> > I found a bug in monochrome bitmaps with inverted colors
> > (color[0]=0xFF, color[1]=0x00). It is problem in translation from
> > XImage into DIB created by CreateDIBSection.
> >
> > Description can be found in my mail from 08 Oct 2005 and 03 Nov 2005.
> > Patch is also attached to this mail.
> >
> > I've got no response and CVS is untouched. So what is wrong with my
> > patch? People from cedega team at least said 'thank you', there is
> > nothing :-(
>
> Well, it seems that Wine doesn't even compile with your patch applied (just
> tried with gcc 4.0.2) - I guess that's at least one of the reasons why it
> wasn't applied...?
>
> See:
> dib.c: In function 'X11DRV_DIB_DoCopyDIBSection':
> dib.c:4186: error: invalid operands to binary ==
> make[2]: *** [dib.o] Error 1
>
> > Thanks for reply,
> >
> >   Oldrich Jedlicka.
>
> Ciao,
> Willie




Re: Bug in monochrome bitmaps

2005-11-23 Thread Willie Sippel
Am Mittwoch, 23. November 2005 09:41 schrieb Oldrich Jedlicka:
> Hi all,
>
> I found a bug in monochrome bitmaps with inverted colors
> (color[0]=0xFF, color[1]=0x00). It is problem in translation from
> XImage into DIB created by CreateDIBSection.
>
> Description can be found in my mail from 08 Oct 2005 and 03 Nov 2005. Patch
> is also attached to this mail.
>
> I've got no response and CVS is untouched. So what is wrong with my patch?
> People from cedega team at least said 'thank you', there is nothing :-(
>
Well, it seems that Wine doesn't even compile with your patch applied (just 
tried with gcc 4.0.2) - I guess that's at least one of the reasons why it 
wasn't applied...?

See:
dib.c: In function 'X11DRV_DIB_DoCopyDIBSection':
dib.c:4186: error: invalid operands to binary ==
make[2]: *** [dib.o] Error 1


> Thanks for reply,
>
>   Oldrich Jedlicka.

Ciao,
Willie

-- 
Willie Sippel

    |  Tritium Studios
 // |  __
 ///|  http://www.tritium-studios.com

<[EMAIL PROTECTED]>




Bug in monochrome bitmaps

2005-11-23 Thread Oldrich Jedlicka
Hi all,

I found a bug in monochrome bitmaps with inverted colors (color[0]=0xFF, 
color[1]=0x00). It is problem in translation from XImage into DIB created 
by CreateDIBSection.

Description can be found in my mail from 08 Oct 2005 and 03 Nov 2005. Patch is 
also attached to this mail.

I've got no response and CVS is untouched. So what is wrong with my patch? 
People from cedega team at least said 'thank you', there is nothing :-(

Thanks for reply,

  Oldrich Jedlicka.
--- dlls/x11drv/dib.c.orig	2005-10-07 01:23:58.0 +
+++ dlls/x11drv/dib.c	2005-10-08 10:02:03.0 +
@@ -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= 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  */
 /*  p