---
name: "ggi_pixel"
section: "3"
platform: "linux"
package: "libggi2-dev"
version: "1:2.2.2-5"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/ggi_color"
---

# ggi\_pixel(3)

LibGGI color description

Part of [ggi\_color(3)](/ggi_color/3.md).

## NAME

**ggi\_color**, **ggi\_pixel** - LibGGI color description

## SYNOPSIS

```
#include <ggi/ggi.h>
typedef struct { uint16_t r,g,b,a; }   ggi_color;
typedef uint32_t   ggi_pixel;
```

## DESCRIPTION

Colors in ggi are described generically through the display-independent **ggi\_color** structure. 16 bit channels are used to ensure sufficient precision on most displays.

**ggi\_pixel**s are display-dependent pixel values.  They are used by all GGI drawing primitives for efficiency.  Use `ggiMapColor(3)` to convert ggi\_colors to ggi\_pixels.

## STRUCTURE MEMBERS

**r**, **g** and **b** correspond to the red, green and blue channels. Since libggi does not deal with alpha compositing, the **a** (alpha) field is mainly there for padding and it is not used by libggi. Setting this value has no effect in libggi itself, and it will most probably not be unmapped correctly from **ggi\_pixel**s. However, some extensions might make use of it, in which case you should refer to their documentation.

**ggi\_pixel**s format depends on the actual display and mode. For those who want to operate directly on pixel values, this format is described in the **[ggi\_pixelformat(3)](/ggi_pixelformat/3.md)** structure.

## PIXEL ARRAYS

Although individual pixels are kept into 32 bits **ggi\_pixel**, arrays of pixels, as used in **ggi\[Get\|Put\]\*** functions, **[ggiPackColors(3)](/ggiPackColors/3.md)** and **[ggiUnpackPixels(3)](/ggiUnpackPixels/3.md)**, are stored in the display specific format, thus packed according to the actual pixel size.  This size is given by the **GT\_SIZE** macro for **graphtype** or the **size** field of the **[ggi\_pixelformat(3)](/ggi_pixelformat/3.md)** structure.

The buffers provided to these functions must be big enough to store or read enough pixels. Although it is safe to use 32 bits per pixel, the optimum size (in bits) can be calculated by multiplying the number of pixel by their size. Don't forget to round up to a multiple of 8 to get the number of bytes.

If you want to access such buffers directly, do *not* use pointer arithmetics with **ggi\_pixel**s.

## SEE ALSO

`ggiMapColor(3)`, `ggi_mode(3)`, `ggi_pixelformat(3)`
