fixed the display on 24-bit and 32-bit displays
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
diff --git a/demos/graph/x11/grx11.c b/demos/graph/x11/grx11.c
index 99d8538..b73fa9e 100644
--- a/demos/graph/x11/grx11.c
+++ b/demos/graph/x11/grx11.c
@@ -1,5 +1,6 @@
#include "grx11.h"
+#define TEST
#ifdef TEST
#include "grfont.h"
@@ -87,6 +88,7 @@
Visual* visual;
Colormap colormap;
int depth;
+ XDepth* xdepth;
Bool gray;
GC gc;
@@ -200,6 +202,40 @@
/* note, the 32-bit modes return a depth of 24, and 32 bits per pixel */
else if ( format->depth == 24 )
{
+#ifdef TEST
+ {
+ int count2;
+ XVisualInfo* visuals;
+ XVisualInfo* visual;
+ const char* string = "unknown";
+
+ template.depth = format->depth;
+ visuals = XGetVisualInfo( display,
+ VisualDepthMask,
+ &template,
+ &count2 );
+ visual = visuals;
+
+ switch (visual->class)
+ {
+ case TrueColor: string = "TrueColor"; break;
+ case DirectColor: string = "DirectColor"; break;
+ case PseudoColor: string = "PseudoColor"; break;
+ case StaticGray : string = "StaticGray"; break;
+ case StaticColor: string = "StaticColor"; break;
+ case GrayScale: string = "GrayScale"; break;
+ }
+
+ printf( "> RGB %04lx:%04lx:%04lx, colors %3d, bits %2d %s\n",
+ visual->red_mask,
+ visual->green_mask,
+ visual->blue_mask,
+ visual->colormap_size,
+ visual->bits_per_rgb,
+ string );
+ visual++;
+ }
+#endif
if ( format->bits_per_pixel == 24 )
add_pixel_mode( gr_pixel_mode_rgb24, format );
@@ -235,13 +271,14 @@
case GrayScale: string = "GrayScale"; break;
}
- printf( "> RGB %02x:%02x:%02x, colors %3d, bits %2d %s\n",
+ printf( "> RGB %04lx:%04lx:%04lx, colors %3d, bits %2d %s\n",
visual->red_mask,
visual->green_mask,
visual->blue_mask,
visual->colormap_size,
visual->bits_per_rgb,
string );
+
#endif
if ( visual->red_mask == 0xf800 &&
visual->green_mask == 0x07e0 &&
@@ -278,11 +315,6 @@
-
-
-
-
-
static
void convert_gray_to_pal8( grXSurface* surface,
int x,
@@ -361,11 +393,11 @@
for ( ; _write < limit; _write += 3, _read++ )
{
- byte color = *_read;
-
- _write[0] =
- _write[1] =
- _write[2] = color;
+ XColor* color = surface->color + *_read;
+
+ _write[0] = color->red;
+ _write[1] = color->green;
+ _write[2] = color->blue;
}
write += target->pitch;
@@ -396,11 +428,8 @@
for ( ; _write < limit; _write += 4, _read++ )
{
byte color = *_read;
-
- _write[0] =
- _write[1] =
- _write[2] =
- _write[3] = color;
+
+ *(unsigned long*)_write = surface->color[color].pixel;
}
write += target->pitch;
@@ -443,7 +472,7 @@
/* convert the rectangle to the target depth for gray surfaces */
if (surface->gray)
{
- switch (surface->depth)
+ switch (surface->xdepth->bits_per_pixel)
{
case 8 : convert_gray_to_pal8( surface, x, y, w, h ); break;
case 16: convert_gray_to_16 ( surface, x, y, w, h ); break;
@@ -635,6 +664,7 @@
if ( image_depth == pixel_depth[i].depth )
{
format = pixel_depth + i;
+ surface->xdepth = format;
break;
}
}
@@ -648,6 +678,7 @@
if ( pixel_modes[i] == bitmap->mode )
{
format = pixel_depth + i;
+ surface->xdepth = format;
break;
}
}
@@ -855,6 +886,7 @@ const grKeyName key_names[] =
{ grKeyReturn, "Return" }
};
+#if 0
int main( void )
{
grSurface* surface;
@@ -932,5 +964,6 @@ int main( void )
}
+#endif /* O */
#endif /* TEST */