Some targets allow visuals to have an indirect mapping of the pixel-value to a color via a programmable palette. This is e.g. true for the 8 bit IBM VGA modes. But even for "direct-mapped" modes, you will need to know which color maps to which pixel-value.
ggi_pixel ggiMapColor(ggi_visual_t vis,ggi_color *col);Get the pixelvalue for the given color. The ggi_color struct has 16 bit wide entries for read (r), green (g), and blue (b) values. Please scale your palette values as necessary.
typedef struct { uint16 r,g,b; } ggi_color;Please note, that such a lookup can be quite expensive (especially for palettized modes) and should thus be avoided e.g. by caching earlier results.
int ggiUnmapPixel(ggi_visual_t vis,ggi_uint pixel,ggi_color *col);Get the color associated with a given pixelvalue.
int ggiPackColors(ggi_visual_t vis,void *buf,ggi_color *cols,int len); int ggiUnpackPixels(ggi_visual_t vis,void *buf,ggi_color *cols,int len);Do the above conversion for multiple pixels.
int ggiSetPaletteVec(ggi_visual_t vis,int s,int len,ggi_color *cmap); int ggiGetPaletteVec(ggi_visual_t vis,int s,int len,ggi_color *cmap);Set or Get a range of palette values (length=len) starting at index# s.