Scroll to navigation

al_color_linear(3) al_color_linear(3)

NAME

al_color_linear - Allegro 5 API

SYNOPSIS

#include <allegro5/allegro_color.h>
ALLEGRO_COLOR al_color_linear(float r, float g, float b)
    

DESCRIPTION

Return an ALLEGRO_COLOR(3) structure from linear sRGB values. Allegro RGB values are assumed to be sRGB. The sRGB standard is in wide use by various display devices. It accounts for a standard gamma correction applied to RGB colors before they get displayed.

Gamma correction means if for example we have a medium gray color specified with al_map_rgb_f(0.5,0.5,0.5) then we do not want the monitor to set the pixel to exactly half the physical maximum intensity, but instead to an intensity that appears to be half as bright as the maximum to the person looking at it. In this case that would be closer to 21% of maximum intensity rather than to 50% intensity.

For some applications it may be useful to specify a color in linear sRGB components, in which case you can use this function. For example:

ALLEGRO_COLOR gray = al_color_linear(0.216, 0.216, 0.216);
char html[8];
al_color_rgb_to_html(gray.r, gray.g, gray.b, html); // "#808080"
    

SINCE

5.2.8

SEE ALSO

al_color_linear_to_rgb(3), al_color_rgb_to_linear(3)

Allegro reference manual