fixed the display on 24-bit and 32-bit displays

This commit is contained in:
David Turner 2000-03-28 16:40:51 +00:00
parent 37379e2170
commit 69473e4efc
1 changed files with 50 additions and 17 deletions

View File

@ -1,5 +1,6 @@
#include "grx11.h" #include "grx11.h"
#define TEST
#ifdef TEST #ifdef TEST
#include "grfont.h" #include "grfont.h"
@ -87,6 +88,7 @@
Visual* visual; Visual* visual;
Colormap colormap; Colormap colormap;
int depth; int depth;
XDepth* xdepth;
Bool gray; Bool gray;
GC gc; GC gc;
@ -200,6 +202,40 @@
/* note, the 32-bit modes return a depth of 24, and 32 bits per pixel */ /* note, the 32-bit modes return a depth of 24, and 32 bits per pixel */
else if ( format->depth == 24 ) 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 ) if ( format->bits_per_pixel == 24 )
add_pixel_mode( gr_pixel_mode_rgb24, format ); add_pixel_mode( gr_pixel_mode_rgb24, format );
@ -235,13 +271,14 @@
case GrayScale: string = "GrayScale"; break; 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->red_mask,
visual->green_mask, visual->green_mask,
visual->blue_mask, visual->blue_mask,
visual->colormap_size, visual->colormap_size,
visual->bits_per_rgb, visual->bits_per_rgb,
string ); string );
#endif #endif
if ( visual->red_mask == 0xf800 && if ( visual->red_mask == 0xf800 &&
visual->green_mask == 0x07e0 && visual->green_mask == 0x07e0 &&
@ -278,11 +315,6 @@
static static
void convert_gray_to_pal8( grXSurface* surface, void convert_gray_to_pal8( grXSurface* surface,
int x, int x,
@ -361,11 +393,11 @@
for ( ; _write < limit; _write += 3, _read++ ) for ( ; _write < limit; _write += 3, _read++ )
{ {
byte color = *_read; XColor* color = surface->color + *_read;
_write[0] = _write[0] = color->red;
_write[1] = _write[1] = color->green;
_write[2] = color; _write[2] = color->blue;
} }
write += target->pitch; write += target->pitch;
@ -396,11 +428,8 @@
for ( ; _write < limit; _write += 4, _read++ ) for ( ; _write < limit; _write += 4, _read++ )
{ {
byte color = *_read; byte color = *_read;
_write[0] = *(unsigned long*)_write = surface->color[color].pixel;
_write[1] =
_write[2] =
_write[3] = color;
} }
write += target->pitch; write += target->pitch;
@ -443,7 +472,7 @@
/* convert the rectangle to the target depth for gray surfaces */ /* convert the rectangle to the target depth for gray surfaces */
if (surface->gray) 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 8 : convert_gray_to_pal8( surface, x, y, w, h ); break;
case 16: convert_gray_to_16 ( 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 ) if ( image_depth == pixel_depth[i].depth )
{ {
format = pixel_depth + i; format = pixel_depth + i;
surface->xdepth = format;
break; break;
} }
} }
@ -648,6 +678,7 @@
if ( pixel_modes[i] == bitmap->mode ) if ( pixel_modes[i] == bitmap->mode )
{ {
format = pixel_depth + i; format = pixel_depth + i;
surface->xdepth = format;
break; break;
} }
} }
@ -855,6 +886,7 @@ const grKeyName key_names[] =
{ grKeyReturn, "Return" } { grKeyReturn, "Return" }
}; };
#if 0
int main( void ) int main( void )
{ {
grSurface* surface; grSurface* surface;
@ -932,5 +964,6 @@ int main( void )
} }
#endif /* O */
#endif /* TEST */ #endif /* TEST */