The EditColormap widget displays two panels that offer alternative methods
for changing one or more colors in the application's colormap. The colors can
be edited individually or in groups using an interpolation algorithm. An
individual color is edited by using an EditColor widget instantiated by the
EditColormap widget or by graphically defining a new value for the red, green
and/or blue components of a color. In addition, provided functions can store
a colormap file on disk, retrieve a colormap file from disk and generate a
colormap to be used during editing.
Specifying the Colors to Edit
The application passes an array of color pixels to the EditColormap widget at
creation time. The array can contain all of the colors in the application's
colormap or just a subset of the colormap. Alternatively, you can specify a
colormap file that contains a list of colors that the EditColormap widget
uses to allocate colors in the colormap.
Creating an EditColormap Widget
An application creates an EditColormap widget as a child of a container widget
or creates an EditColormap dialog using a provided function. During the
creation process, the application specifies via resources the colors to be
edited and the components to be included on the EditColormap panels.
Getting the Edited Colors
Because the colors passed to the EditColormap widget are contained in
read-write color cells, the application's colors are updated dynamically as the
colors are edited. Therefore, the edited colors can be referenced directly from
the colormap during or after the edit operation.
Color Square Panel
When an EditColormap widget is first displayed, the end-user sees the Color
Square Panel. This panel displays the spectrum of colors in the pixel array and
an array of color squares depicting each color passed to the EditColormap
widget. The panel also provides a control for specifying the interpolation
algorithm used when a group of colors is edited. Also on this panel is a
slider that shifts the colors in the color array to the right so that they
rotate from the last cell to the first cell. The sequence numbers of the
elements in the color array can also be displayed. Finally, a control is
provided to display either this panel or the Diagram Panel.
Color Diagram Panel
When the end-user selects the Diagram Panel radio button on the Color Square
Panel, then the Color Square Panel is replaced by the Diagram Panel. This panel
contains the spectrum of colors in the colormap and a graph of the red, green
and blue components of every color in the array passed to the EditColormap
widget. The diagram has a scale along the vertical axis for the intensities
of the color components and a scale along the horizontal axis for the sequence
number of the color in the pixel array. Also contained on this panel, are check
boxes for specifying which of the color components is to be edited.
Colormaps
The EditColormap widget edits the RGB values associated with an array of pixels
from the application's colormap. The programmer can allocate a colormap using
standard X functions, use EditColormap functions to generate a colormap before
creating an EditColormap widget or specify a colormap file that the
EditColormap widget will use to generate a colormap. Note that the colormap
passed to an EditColormap widget must contain only read-write color cells and
that the EditColormap widget will allocate three read-only cells in the
colormap for the red, green and blue check boxes on the Color Diagram Panel.
Colormap Files
The EditColormap widget can create and read a file that defines a colormap.
Functions are provided for creating and using a colormap file. The colormap
file is formatted as an ASCII file containing a line giving the number of
colors defined in the colormap file, followed by lines specifying the red,
green and blue intensities colors as integers between 0 and 65535. The
following is an example of a colormap file where the first color is black and
the last color is white.
Saving a Colormap to a File
The array of pixels being edited with an EditColormap widget can be saved by
the end-user to a file on disk. When the end-user clicks on the Save
pushbutton, the Save Colormap File Panel appears. Using the Save Colormap
Panel, the user specifies a filename for the colormap file.
Editing an Individual Color with the Color Square Panel
To edit an individual color using the Color Square Panel, double-click on the
color square containing the color you wish to edit. An EditColor dialog box
will appear for editing the color selected. When you use the EditColor widget
to change the color, the corresponding color cell is dynamically updated on the
Color Square Panel.
Editing a Group of Colors with the Color Square Panel
To edit a contiguous group of colors, click on two color squares that bound the
group of colors to be edited so that the two color squares are highlighted.
Select the interpolation algorithm to be used to change the colors between
the two highlighted squares. Then double-click on one of the two highlighted
color squares. An EditColor dialog box will appear for editing the selected
color. As you edit the selected color, the EditColormap widget uses the
selected interpolation method to change the color of all of the colors between
the two selected squares.
Editing a Sequence of Colors with the Color Diagram Panel
To edit a contiguous group of colors, first select the color components(s)
(Red, Green and/or Blue) that are to be changed by checking the appropriate
check boxes. Then position the cursor so that it lies horizontally at the
location of the leftmost color to be edited and vertically at the location of
the desired color intensity level. Then click and hold down the mouse button
while moving the cursor horizontally to the location of the rightmost color to
be edited and vertically to the location of the new desired intensity level.
When you release the mouse button, the EditColormap widget will interpolate
linearly between the selected intensities of the leftmost and rightmost colors.
EditColormap Color Square Panel
When an EditColormap widget is first displayed it looks like the picture below.
Figure 8: EditColormap with Color Square Panel.
EditColormap Color Diagram Panel
When the end-user selects the Diagram Panel radio button, the following panel
appears.