ref: 69473e4efc4162cc837450e86b2621594e12af6e
parent: 37379e2170f4e8c28bb9271929dcca76eab22a07
author: David Turner <[email protected]>
date: Tue Mar 28 11:40:51 EST 2000
fixed the display on 24-bit and 32-bit displays
--- 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,7 +271,7 @@
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,
@@ -242,6 +278,7 @@
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 @@
{ grKeyReturn, "Return" }
};
+#if 0
int main( void )
{
grSurface* surface;
@@ -932,5 +964,6 @@
}
+#endif /* O */
#endif /* TEST */