Color Functions

The following functions are used to manipulate individual color and to create or modify a color table structure which is used for materials whose type is XintMATERIAL_COLOR_INDEX.

Function NameDescription
XintView3DCreateColorTableCreates a new color table.
XintView3DColor4ToPixelConverts a XintColor4 value into a pixel.
XintView3DColorRecToColorTableCreates or updates a color table from a XintColorRec structure.
XintView3DColorTableDataReturns the colors and number of colors of the specified color table.
XintView3DColorTableFreeFrees a color table.
XintView3DPixelToColor4Converts a color pixel to a XintColor4 value.
XintView3DReadColorTableReads a color table stored in a file and create or update a color table.
XintView3DSetColor4ByNameConverts a color specified by a name into a XintColor4 value.
XintView3DUpdateColorTableUpdates an existing color table.


XintView3DCreateColorTable

This function creates a new color table.

     XintView3DColorTable * XintView3DCreateColorTable (...)

XintColor4 *colorsList of colors.
intcountNumber of colors in array colors.

The function returns a pointer to the color table created.


XintView3DColor4ToPixel

This function converts a XintColor4 value into an X pixel value.

     void XintView3DColor4ToPixel(...)

Widgetview3dView3D widget.
XintColor4colorColor to convert.
Pixel *pixelReturns the closest pixel value corresponding to color.


XintView3DColorRecToColorTable

This function creates or updates a color table from a XintColorRec structure. Structure XintColorRec is used by some other INT widgets, such as Contour or Seismic to store colormap information.

     XintView3DColorTable *XintView3DColorRecToColorTable (...)

XintView3DColorTable *color_tableSpecify NULL to create a new color_table, or pass an existing color table to update it.
WidgetwidgetWidget that is using color_rec to store its color information.
XintColorRec *color_recPointer to the color record structure.

This function returns the address of a new color table if argument color_table was set to NULL. Otherwise it returns color_table.


XintView3DColorTableData

This function returns the number of colors and color values stored in a color table.

     XintColor4 *XintView3DColorTableData (...)

XintView3DColorTable *color_tableSpecify a color table.
int *ncolorsReturns the number of colors in the color table.

This function returns a pointer to the array of colors contained in the color table. The pointer should not be freed by the application.


XintView3DColorTableFree

This function frees an existing color table. You must make sure that no material references the color table before you attempt to free it.

     void XintView3DColorTableFree (...)

XintView3DColorTable *color_tableColor table to free.


XintView3DPixelToColor4

This function converts an X pixel value into a XintColor4 value.

     void XintView3DPixelToColor4(...)

widgetview3dView3D widget.
PixelpixelPixel value to convert.
XintColor4colorAfter function returns, contains the color specification corresponding to pixel.


XintView3DReadColorTable

This function creates or updates a color table from a file containing a color table description. In the case of an update, if filename contains less colors than the color table to be updated, the number of colors in the updated color table will not be changed and only the first ncolors (number of colors in filename) will be updated.

     XintView3DColorTable *XintView3DReadColorTable (...)

XintView3DColorTable *color_tableSpecify NULL to create a new color_table, or pass an existing color table to update it.
char *filenameSpecifies the name of a file containing the color table description.

This function returns the address of a new color table if argument color_table was set to NULL. Otherwise it returns color_table. If the file specified in argument filename could not be opened or did not contain a valid color table description, NULL is returned.

The colormap file is formatted as an ASCII file containing a line giving the number of colors defined in the colormap, followed by lines specifying the red, green and blue intensities as integers between 0 and 65535. An optional transparency is specified as a floating point value between 0 and 1. The following is an example of a valid colormap file where the first color is black and the last color is white.

    ncolors = 7
    0        0        0        1.0
    10000    1870     5482     1.0
    30942    20056    59035    1.0
    1004     6003     900      1.0
    10023    4938     5933     1.0
    5833     28000    3500     1.0
    65535    65535    65535    1.0


XintView3DSetColor4ByName

This function converts a color name into a XintColor4 value.

     Boolean XintView3DSetColor4ByName(...)

Widgetview3dID of widget (does not need to be a View3D widget).
char *color_nameColor name to convert.
XintColor4colorContains on return the color specification corresponding to color_name.

The function returns False if it did not recognize the color name, True otherwise.


XintView3DUpdateColorTable

This function updates an existing color table. If the new number of colors specified is less than the number of colors in the original color table, the number of colors in the updated color table will stay unchanged and only the first ncolors will be updated.

     void XintView3DUpdateColorTable (...)

XintView3DColorTable *color_tableSpecifies the color table to update.
XintColor4 *colorsNew list of colors.
intncolorsNumber of colors in array colors.