rgbpix

RGBPIX(3G)                                                          RGBPIX(3G)



NAME
       RGB, rgbpix, rdcolmap, wrcolmap

SYNOPSIS
       #include <libc.h>
       #include <libg.h>

       unsigned long rgbpix(Bitmap *b, RGB rgb)

       void          rdcolmap(Bitmap *b, RGB *map)

       void          wrcolmap(Bitmap *b, RGB *map)

DESCRIPTION
       Colors are described by the red, green, and blue light intensities, in
       an RGB datum:

              typedef
              struct RGB {
                    unsigned long red;
                    unsigned long green;
                    unsigned long blue;
              } RGB;

       Zero intensity means there is no component of the given color; hence,
       black is represented by zero in all three positions and white has the
       maximum unsigned long value in all three positions.

       Some of the graphics functions, such as point (see bitblt(3)), take a
       pixel value argument, which is a single unsigned long.  For a given
       bitmap, rgbpix returns the pixel value with a color closest to the
       color represented by the rgb argument.

       There is a colormap associated with each Bitmap.  A colormap is an
       array of RGBs, of length 2^(2^ldepth), giving the colors for pixels 0,
       1, 2, etc.

       Rdcolormap reads the colormap for the given bitmap into the provided
       map, which must have enough space to hold it.  Wrcolormap associates
       the given colormap with the given bitmap, if possible.  (The hardware
       might not allow this.)

CAVEAT
       The X implementation of libg uses whatever colourmap is the default
       when it starts up.  A call to rgbpix will result in a call to
       XAllocColor and the allocation of a new colour in the application's
       colourmap if there is room.  If no new colours can be allocated rgbpix
       will return the closest pixel value approximating the requested colour.
       If an application calls wrcolmap the default colourmap is replaced with
       the new colourmap and from then on rgbpix will deal with the new
       colourmap.

BUGS
       These functions only work for the screen bitmap.  This interface will
       have to be refined for screens with ldepth > 3.

SEE ALSO
       graphics(3), bitblt(3)




                                                                    RGBPIX(3G)