Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11692) New fogging broken on 16-bit displays
Home

[Freeciv-Dev] (PR#11692) New fogging broken on 16-bit displays

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: r_q_smith@xxxxxxxxx
Subject: [Freeciv-Dev] (PR#11692) New fogging broken on 16-bit displays
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 26 Dec 2004 21:01:24 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11692 >

> [r_q_smith@xxxxxxxxx - Sat Dec 25 22:05:33 2004]:
> 
> The new fogging code produces some very odd results on my 16-bit
> display.  To be honest, I'm not entirely sure what the logic behind the
> current gode in fog_sprite is, but this:
> 
> guint8 red = ((pixel & ftile->visual->red_mask) >>
> ftile->visual->red_shift) / 2;
> guint8 green = ((pixel & ftile->visual->green_mask) >>
> ftile->visual->green_shift) / 2;
> guint8 blue = ((pixel & ftile->visual->blue_mask) >>
> ftile->visual->blue_shift) / 2;
> 
> to produce the new red, green, and blue components is both simpler and 
> works on both 16 and 24-bit displays.

Seems reasonable.  Here's a patch.

-jason

Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.142.2.8
diff -u -r1.142.2.8 mapview.c
--- client/gui-gtk-2.0/mapview.c        25 Dec 2004 19:50:24 -0000      
1.142.2.8
+++ client/gui-gtk-2.0/mapview.c        27 Dec 2004 05:00:57 -0000
@@ -915,15 +915,12 @@
     for (y = 0; y < sprite->height; y++) {
       guint32 pixel =  gdk_image_get_pixel(ftile, x, y);
 
-      guint8 red = (((pixel & ftile->visual->red_mask) << 
-                    (32 - ftile->visual->red_shift 
-                     - ftile->visual->red_prec)) >> 24) / 2; 
-      guint8 green = (((pixel & ftile->visual->green_mask) <<
-                      (32 - ftile->visual->green_shift 
-                       - ftile->visual->green_prec)) >> 24) / 2;
-      guint8 blue = (((pixel & ftile->visual->blue_mask) <<
-                     (32 - ftile->visual->blue_shift 
-                      - ftile->visual->blue_prec)) >> 24) / 2;
+      guint8 red = ((pixel & ftile->visual->red_mask)
+                   >> ftile->visual->red_shift) / 2;
+      guint8 green = ((pixel & ftile->visual->green_mask)
+                     >> ftile->visual->green_shift) / 2;
+      guint8 blue = ((pixel & ftile->visual->blue_mask)
+                    >> ftile->visual->blue_shift) / 2;
       guint32 result = red << ftile->visual->red_shift
        | green << ftile->visual->green_shift          
        | blue << ftile->visual->blue_shift;

[Prev in Thread] Current Thread [Next in Thread]