colorfile

[ XITE Reference Manual | XITE home ]

Contents


Name

colorfile, color_convertfromimg, color_create, color_read, color_write, PrintColortable, read_colormap - Read, write and create colortables and colormaps

Syntax

 #include <xite/color.h>

 IMAGE color_create( Color_tab coltab,
    char* name, int len );

 BiffStatus color_read( char* file_name,
    Color_tab coltab, char** name, int* len );

 BiffStatus color_write( char* file_name,
    Color_tab coltab, char* name, int len );

 BiffStatus color_convertfromimg( IMAGE img,
    Color_tab coltab, char** name, int* len );

 void PrintColortable( Color_cell* col, int len,
    int hex, FILE* fileptr );

 void read_colormap( FILE *file, Color_cell *ctab,
    int *len );

Description

color_create returns an IMAGE containing the colortab (or NULL if error).

color_read reads a colortable from file file_name into coltab. The name of the colortable is returned in name, and the length of the colortable is returned in len. The routine returns Iok, Iopenerr or Icolpixerr. The pixelvalue for each colorcell in the file is tripled in the returned colortable by shifting and OR-ing the original pixelvalue so that the colortable can also be used by 24-bit composite-colormap visuals (DirectColor and TrueColor).

color_write writes a colortable coltab of length len to file file_name with title name. The routine returns Iok, Iopenerr or Ibifferr. Only the PseudoColor part of the pixelvalue (maximum 8 bits) is stored in the file.

color_convertfromimg converts a color table from IMAGE format to colortable format. The pixelvalue for each colorcell is tripled in the returned colortable by shifting and OR-ing the original pixelvalue so that the colortable can also be used by composite-colormap visuals (DirectColor and TrueColor).

PrintColortable prints col in an ascii format which can be given as input to read_colormap (and the program mct(1)). The output consists of 4 columns which are colortable pixelvalue, red, green and blue (in this order).

The pixelvalue column printed by PrintColortable can be given as decimals or hexadecimals (hex nonzero). Only the PseudoColor part of the pixelvalue is printed.

read_colormap can read the ascii formatted colormap printed by PrintColortable. The resulting colortable may be used on 8-bit PseudoColor visuals as well as on 24-bit composite-colormap visuals (DirectColor and TrueColor).

Each line in the file describes a color in the colortable. The line-format is

 <colornumber> <red-val> <green-val> <blue-val>

colornumber is an unsigned integer. It is used as an index to lookup red-val, green-val and blue-val.

red-val, green-val and blue-val are the intensities of the colors in the range 0 - 65535. A special notation
 c1 r1 g1 b1
 :
 c2 r2 g2 b2
defines a linear stretch in the range c1 to c2, i.e. the colornumbers in the range c1 to c2 will get red intensities in the range r1 to r2, green in the range g1 to g2 and blue in the range b1 to b2. The ranges are linearly interpolated.

Lines with a # in coloumn 1 are treated as comments.

See also

mct(1), color2ascii(1), color2ascii(3)

Author

Otto Milvang and Svein Bøe

Bug fix

24.07.92 Knut-Andreas Lie

Examples

Id

$Id: colorfile.c,v 1.38 1996/11/29 15:11:42 svein Exp $