Re: Adding support for 4 bit color




Walt Pohl <pohl@math.washington.edu> writes:

> The code for visuals is in gdkvisuals.c.  There's an array of possible
> depths, called possible_depths, and you would need to add 4 to that (and
> add one to npossible_depths).  Also, you would probably need to edit
> gdk_init_visuals -- it ranks the best visuals for a depth, and for 8 bit
> color, it chooses GDK_PSEUDO_COLOR, otherwise it chooses GDK_TRUE_COLOR.
> Presumably for 4 bit color, GDK_PSEUDO_COLOR is also the best choice.  Let
> me know if you have any problems.

Actually, for 4 bit color, you probably want StaticColor, (or maybe
TrueColor - 3x2x2 color cube?). If programs just allocated the first
16 colors they wanted into the 16-space color map (14 actually, white
+ black are always preallocated), you'd probably end up with 16 grays
or 16 blues, or something - it is better to let the server pick
a small fixed palette (which is what StaticColor is).
 
> I've wondered why GDK only supports certain depths:  1, 8, 15, 16, 24 (I
> think).  Are other video cards or X displays that don't have at least 8
> bit color rare?

GDK comes from originally from the GIMP. And it's pretty nigh
impossible to decently support full-color images, even with dithering,
on a 4 bit display; adding 4 bit support to GDK is pretty trivial, but
to get GTK+ fully working properly, you need to add support for
rendering 4 bit color to gtkpreview.c - which expects either to have
TrueColor visual, or a Pseudocolor visual where it can allocate a
color cube. It isn't so obvious how to proceed in fixing GtkPreview 
up.

Regards,
                                                  Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]