---
name: "ggiMapColor"
section: "3ggi"
platform: "linux"
package: "libggi2-dev"
version: "1:2.0.1-2"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/ggiMapColor/3ggi"
---

# ggiMapColor(3ggi)

Convert from ggi\_color(s) to ggi\_pixel(s) and vice versa

## NAME

ggiMapColor, ggiUnmapPixel, ggiPackColors, ggiUnpackPixels - Convert from ggi\_color(s) to ggi\_pixel(s) and vice versa

## SYNOPSIS

**#include \<ggi/ggi.h\>**

**ggi\_pixel ggiMapColor(ggi\_visual\_t** *vis***, ggi\_color \****col***);**

**int ggiUnmapPixel(ggi\_visual\_t** *vis***,**  **ggi\_pixel** *pixel***, ggi\_color \****col***);**

**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***);** .SH "DESCRIPTION"

**ggiMapColor** gets the pixelvalue for the given color.

**ggiUnmapPixel** gets the color associated with the given pixelvalue.

**ggiPackColors** converts the colors in *cols* to  pixelvalues in *buf*.  The output from this function is suitable for input to the **ggiPut{HLine,VLine,Box}** functions.

**ggiUnpackPixels** converts the pixelvalues in *buf* to individual elements of *cols*. This function maybe used to convert buffers output by the **ggiGet{HLine,VLine,Box}** functions from the pixelvalue representation to their actual colors.

The buffers output from **ggiPackColors** and the input to **ggiUnpackPixels** are in the same format as the get/put buffers.  Their format is defined in **ggi\_pixelformat**.

Try to cache the results of color lookups in your application for efficiency purposes.

## RETURN VALUE

**ggiMapColor** returns a **ggi\_pixel**.

**ggiUnmapPixel**, **ggiPackColors**, and **ggiUnpackPixels** returns 0 for OK, otherwise an error code.
