frei0r: Color Models

- Main Page
- Modules
- Data Structures
- Files
- Directories

# Color Models

## Defines
#define | F0R_COLOR_MODEL_BGRA8888 0
#define | F0R_COLOR_MODEL_RGBA8888 1
#define | F0R_COLOR_MODEL_PACKED32 2

## Detailed Description

List of supported color models.

Note: the color models are endian independent, because the color components are defined by their positon in memory, not by their significance in an uint32_t value.

For effects that work on the color components, RGBA8888 is the recommended color model for frei0r-1.1 effects. For effects that only work on pixels, PACKED32 is the recommended color model since it helps the application to avoid unnecessary color conversions.

Effects can choose an appropriate color model, applications must support all color models and do conversions if necessary. Source effects must not use the PACKED32 color model because the application must know in which color model the created framebuffers are represented.

For each color model, a frame consists of width*height pixels which are stored row-wise and consecutively in memory. The size of a pixel is 4 bytes. There is no extra pitch parameter (i.e. the pitch is simply width*4).

The following additional constraints must be honored:

- The top-most line of a frame is stored first in memory.
- A frame must be aligned to a 16 byte border in memory.
- The width and height of a frame must be positive
- The width and height of a frame must be integer multiples of 8

These constraints make sure that each line is stored at an address aligned to 16 byte.

## Define Documentation

#define F0R_COLOR_MODEL_BGRA8888 0

| In BGRA8888, each pixel is represented by 4 consecutive unsigned bytes, where the first byte value represents the blue, the second the green, and the third the red color component of the pixel. The last value represents the alpha value.

#define F0R_COLOR_MODEL_PACKED32 2

| In PACKED32, each pixel is represented by 4 consecutive bytes, but it is not defined how the color componets are stored. The true color format could be RGBA8888, BGRA8888, a packed 32 bit YUV format, or any other color format that stores pixels in 32 bit. This is useful for effects that don't work on color but only on pixels (for example a mirror effect). Note that source effects must not use this color model.

#define F0R_COLOR_MODEL_RGBA8888 1

| In RGBA8888, each pixel is represented by 4 consecutive unsigned bytes, where the first byte value represents the red, the second the green, and the third the blue color component of the pixel. The last value represents the alpha value.