[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Patch for 8bpp display



Hello

This is the patch for handling a 8bpp display (256 colours). This patch
doesn't work with the fullscreen mode (option -F). I don't know why. So
thank you in advance if anybody is able to fix this problem.

Vincent

========================
--- xwin.c Wed Jan 24 14:22:11 2001
+++ xwin.VPY Wed Jan 24 12:08:06 2001
@@ -606,7 +606,8 @@
}
-#define Ctrans(col) (colmap[col])
+//#define Ctrans(col) (colmap[col])
+#define Ctrans(col) (bpp == 8 ? col : colmap[col])
// unroll defines, used to make the loops a bit more readable...
#define unroll8Expr(uexp) uexp uexp uexp uexp uexp uexp uexp uexp
@@ -860,6 +861,8 @@
HCOLOURMAP
ui_create_colourmap (COLOURMAP * colours)
{
+if (bpp > 8)
+ {
COLOURENTRY *entry;
int i, ncolours = colours->ncolours;
uint32 *nc = xmalloc (sizeof (*colmap) * ncolours);
@@ -876,12 +879,42 @@
nc[i] = xc.pixel;
}
return nc;
+ }
+ else
+ {
+ COLOURENTRY *entry;
+ XColor *xcolours, *xentry;
+ Colormap map;
+ int i, ncolours = colours->ncolours;
+
+ xcolours = xmalloc(sizeof(XColor) * ncolours);
+ for (i = 0; i < ncolours; i++)
+ {
+ entry = &colours->colours[i];
+ xentry = &xcolours[i];
+
+ xentry->pixel = i;
+ xentry->red = entry->red << 8;
+ xentry->blue = entry->blue << 8;
+ xentry->green = entry->green << 8;
+ xentry->flags = DoRed | DoBlue | DoGreen;
+ }
+
+ map = XCreateColormap(display, wnd, visual, AllocAll);
+ XStoreColors(display, map, xcolours, ncolours);
+
+ xfree(xcolours);
+ return (HCOLOURMAP)map;
+ }
}
void
ui_destroy_colourmap (HCOLOURMAP map)
{
+if (bpp > 8)
xfree (map);
+ else
+ XFreeColormap(display, (Colormap)map);
}
void
@@ -891,7 +924,10 @@
/* XXX, change values of all pixels on the screen if the new colmap
* doesn't have the same values as the old one? */
// XSetWindowColormap(display, wnd, (Colormap)map);
+if (bpp > 8)
colmap = map;
+ else
+ XSetWindowColormap(display, wnd, (Colormap)map);
}
void
@@ -1570,6 +1606,3 @@
return d2;
}
-
-
-