Here's a proposed patch.
Christoph -- this was your bug report, could you test this?
--
Brian
Index: color.c
===================================================================
RCS file: /cvsroot/ggi/ggi-core/libggi/default/color/color.c,v
retrieving revision 1.1.1.1
diff -U2 -r1.1.1.1 color.c
--- color.c 2001/05/12 23:01:33 1.1.1.1
+++ color.c 2001/06/03 03:13:20
@@ -160,5 +160,6 @@
}
-int GGI_color_TRUE_unmappixel(ggi_visual *vis, ggi_pixel pixel, ggi_color *col)
+int GGI_color_TRUE_unmappixel_gte8(ggi_visual *vis, ggi_pixel pixel,
+ ggi_color *col)
{
color_truepriv *priv = vis->colorpriv;
@@ -166,8 +167,90 @@
col->r = DOSHIFT(pixel & priv->red_mask,
priv->red_unmap);
+ col->r |= col->r >> priv->red_tot;
col->g = DOSHIFT(pixel & priv->green_mask,
priv->green_unmap);
+ col->g |= col->g >> priv->green_tot;
col->b = DOSHIFT(pixel & priv->blue_mask,
priv->blue_unmap);
+ col->b |= col->b >> priv->blue_tot;
+
+ return 0;
+}
+
+int GGI_color_TRUE_unmappixel_gte4(ggi_visual *vis, ggi_pixel pixel,
+ ggi_color *col)
+{
+ color_truepriv *priv = vis->colorpriv;
+
+ col->r = DOSHIFT(pixel & priv->red_mask,
+ priv->red_unmap);
+ col->r |= col->r >> priv->red_tot;
+ col->r |= col->r >> (priv->red_tot << 1);
+ col->g = DOSHIFT(pixel & priv->green_mask,
+ priv->green_unmap);
+ col->g |= col->g >> priv->green_tot;
+ col->g |= col->g >> (priv->green_tot << 1);
+ col->b = DOSHIFT(pixel & priv->blue_mask,
+ priv->blue_unmap);
+ col->b |= col->b >> priv->blue_tot;
+ col->b |= col->b >> (priv->blue_tot << 1);
+
+ return 0;
+}
+
+
+int GGI_color_TRUE_unmappixel_gte2(ggi_visual *vis, ggi_pixel pixel,
+ ggi_color *col)
+{
+ color_truepriv *priv = vis->colorpriv;
+
+ col->r = DOSHIFT(pixel & priv->red_mask,
+ priv->red_unmap);
+ col->r |= col->r >> priv->red_tot;
+ col->r |= col->r >> (priv->red_tot << 1);
+ col->r |= col->r >> (priv->red_tot << 2);
+ col->g = DOSHIFT(pixel & priv->green_mask,
+ priv->green_unmap);
+ col->g |= col->g >> priv->green_tot;
+ col->g |= col->g >> (priv->green_tot << 1);
+ col->g |= col->g >> (priv->green_tot << 2);
+ col->b = DOSHIFT(pixel & priv->blue_mask,
+ priv->blue_unmap);
+ col->b |= col->b >> priv->blue_tot;
+ col->b |= col->b >> (priv->blue_tot << 1);
+ col->b |= col->b >> (priv->blue_tot << 2);
+
+ return 0;
+}
+
+/* For the rare but extremely painful cases. */
+int GGI_color_TRUE_unmappixel_gte1(ggi_visual *vis, ggi_pixel pixel,
+ ggi_color *col)
+{
+ color_truepriv *priv = vis->colorpriv;
+
+ if (priv->red_tot != 1) {
+ col->r = DOSHIFT(pixel & priv->red_mask,
+ priv->red_unmap);
+ col->r |= col->r >> priv->red_tot;
+ col->r |= col->r >> (priv->red_tot << 1);
+ col->r |= col->r >> (priv->red_tot << 2);
+ } else col->r = (pixel & priv->red_mask) ? 0xffff : 0x0000;
+
+ if (priv->green_tot != 1) {
+ col->g = DOSHIFT(pixel & priv->green_mask,
+ priv->green_unmap);
+ col->g |= col->g >> priv->green_tot;
+ col->g |= col->g >> (priv->green_tot << 1);
+ col->g |= col->g >> (priv->green_tot << 2);
+ } else col->g = (pixel & priv->green_mask) ? 0xffff : 0x0000;
+
+ if (priv->blue_tot != 1) {
+ col->b = DOSHIFT(pixel & priv->blue_mask,
+ priv->blue_unmap);
+ col->b |= col->b >> priv->blue_tot;
+ col->b |= col->b >> (priv->blue_tot << 1);
+ col->b |= col->b >> (priv->blue_tot << 2);
+ } else col->b = (pixel & priv->blue_mask) ? 0xffff : 0x0000;
return 0;
Index: color.h
===================================================================
RCS file: /cvsroot/ggi/ggi-core/libggi/default/color/color.h,v
retrieving revision 1.1.1.1
diff -U2 -r1.1.1.1 color.h
--- color.h 2001/05/12 23:01:33 1.1.1.1
+++ color.h 2001/06/03 03:13:21
@@ -37,5 +37,8 @@
ggifunc_unmappixel GGI_color_PAL_unmappixel;
-ggifunc_unmappixel GGI_color_TRUE_unmappixel;
+ggifunc_unmappixel GGI_color_TRUE_unmappixel_gte8;
+ggifunc_unmappixel GGI_color_TRUE_unmappixel_gte4;
+ggifunc_unmappixel GGI_color_TRUE_unmappixel_gte2;
+ggifunc_unmappixel GGI_color_TRUE_unmappixel_gte1;
ggifunc_unmappixel GGI_color_GREY_unmappixel;
@@ -60,10 +63,13 @@
int red_unmap;
int red_mask;
+ int red_tot;
int green_map;
int green_unmap;
int green_mask;
+ int green_tot;
int blue_map;
int blue_unmap;
int blue_mask;
+ int blue_tot;
} color_truepriv;
Index: visual.c
===================================================================
RCS file: /cvsroot/ggi/ggi-core/libggi/default/color/visual.c,v
retrieving revision 1.1.1.1
diff -U2 -r1.1.1.1 visual.c
--- visual.c 2001/05/12 23:01:32 1.1.1.1
+++ visual.c 2001/06/03 03:13:21
@@ -53,10 +53,13 @@
priv->red_unmap = 16 - redtot;
priv->red_mask = LIBGGI_PIXFMT(vis)->red_mask;
+ priv->red_tot = redtot;
priv->green_map = greentot - 16;
priv->green_unmap = 16 - greentot;
priv->green_mask = LIBGGI_PIXFMT(vis)->green_mask;
+ priv->green_tot = greentot;
priv->blue_map = bluetot - 16;
priv->blue_unmap = 16 - bluetot;
priv->blue_mask = LIBGGI_PIXFMT(vis)->blue_mask;
+ priv->blue_tot = bluetot;
} else if (GT_SCHEME(LIBGGI_GT(vis)) == GT_PALETTE ||
GT_SCHEME(LIBGGI_GT(vis)) == GT_STATIC_PALETTE) {
@@ -94,5 +97,21 @@
case GT_TRUECOLOR:
vis->opcolor->mapcolor = GGI_color_TRUE_mapcolor;
- vis->opcolor->unmappixel = GGI_color_TRUE_unmappixel;
+ if (COLOR_TRUEPRIV(vis)->red_tot >= 8 &&
+ COLOR_TRUEPRIV(vis)->green_tot >= 8 &&
+ COLOR_TRUEPRIV(vis)->blue_tot >= 8)
+ vis->opcolor->unmappixel =
+ GGI_color_TRUE_unmappixel_gte8;
+ else if (COLOR_TRUEPRIV(vis)->red_tot >= 4 &&
+ COLOR_TRUEPRIV(vis)->green_tot >= 4 &&
+ COLOR_TRUEPRIV(vis)->blue_tot >= 4)
+ vis->opcolor->unmappixel =
+ GGI_color_TRUE_unmappixel_gte4;
+ else if (COLOR_TRUEPRIV(vis)->red_tot >= 2 &&
+ COLOR_TRUEPRIV(vis)->green_tot >= 2 &&
+ COLOR_TRUEPRIV(vis)->blue_tot >= 2)
+ vis->opcolor->unmappixel =
+ GGI_color_TRUE_unmappixel_gte2;
+ else vis->opcolor->unmappixel =
+ GGI_color_TRUE_unmappixel_gte1;
break;