Description of color problem
To avoid a continuous call of XAllocColor(3x) and XFreeColor(3x), colors MUST
be allocated at init time.
We must take care of different class of visual. There are 6 classes:
- StaticGray, GrayScale, StaticColor, PseudoColor, TrueColor and DirectColor.
Each class have different depth. Allocating color for 24 planes is hugly.
On a 8 color plane pseudoColor display, color is shared beetween application.
Motif allocate , also, some color.
Partial Solve
- Display with less than or equal 2 planes are like black and white.
-
For StaticGray, GrayScale, StaticColor, PseudoColor with more than 2 planes,
We create a color cube [nblue][ngreen][nred]. For Gray , nblue=1 and ngreen=1.
Dimension of cube is computed depending of the available color.
This class of display have few plane (usualy 8), so the size of color
cube is small.
-
For TrueColor and DirectColor, (have usualy a lot of planes -16 or 24-) we alloc
also a color cube. But, at this time, we must do better, specially for
TrueColor.
- HTMLwidget has 2 colors stack, one for background (BODY TABLE TR TH TD),
one for foreground (FONT BASEFONT BODY ANCHOR-alink-)
Functions
- HTMLInitColors(Widget w, unsigned int nc)
Call it ONE time. w is usually the TopLevelShell return by XtAppInitialize.
If nc is null, let the function allocate colors. If nc is not null, nc
is the max number of color. Number of colors allocated is less than nc.
- Pixel HTMLXColorToPixel(XColor * xc)
For a given RGB color in xc, return the pixel entry of the current colormap.
Color is an approximation.
- void HTMLPixelToXColor(XColor * c)
Return RGB value for a given c->pixel.
- void MMInitWidgetColorStack(HTMLWidget hw)
Initialize the 2 color stack HTMLwidget.
- void MMResetWidgetColorStack(HTMLWidget hw);
Free the color stack.
- Pixel MMPopColorBg(HTMLWidget hw);
Pixel MMPopColorFg(HTMLWidget hw);
Pixel MMPushColorBg(HTMLWidget hw, Pixel new_pix);
Pixel MMPushColorFg(HTMLWidget hw, Pixel new_pix);
self explanatory.
TODO
- File : libhtmlw/HTMLcolors.c
-
- write better code for Truecolor and DirectColor.
-
- Speedup HTMLPixelToXColor.