- geta — Extract a color component from the current pixel format.
- geta32 — Extract the alpha component form a 32-bit pixel format color.
- geta_depth — Extract a color component from a color in a specified pixel format.
- getb — Extract a color component from the current pixel format.
- getb15 — Extract a color component from the specified pixel format.
- getb16 — Extract a color component from the specified pixel format.
- getb24 — Extract a color component from the specified pixel format.
- getb32 — Extract a color component from the specified pixel format.
- getb8 — Extract a color component from the specified pixel format.
- getb_depth — Extract a color component from a color in a specified pixel format.
- getg — Extract a color component from the current pixel format.
- getg15 — Extract a color component from the specified pixel format.
- getg16 — Extract a color component from the specified pixel format.
- getg24 — Extract a color component from the specified pixel format.
- getg32 — Extract a color component from the specified pixel format.
- getg8 — Extract a color component from the specified pixel format.
- getg_depth — Extract a color component from a color in a specified pixel format.
- getr — Extract a color component from the current pixel format.
- getr15 — Extract a color component from the specified pixel format.
- getr16 — Extract a color component from the specified pixel format.
- getr24 — Extract a color component from the specified pixel format.
- getr32 — Extract a color component from the specified pixel format.
- getr8 — Extract a color component from the specified pixel format.
- getr_depth — Extract a color component from a color in a specified pixel format.
- makeacol — Converts RGBA colors into display dependent pixel formats.
- makeacol32 — Converts an RGBA color into a 32-bit display pixel format.
- makeacol_depth — Converts RGBA colors into display dependent pixel formats.
- makecol — Converts an RGB value into the current pixel format.
- makecol15 — Converts an RGB value into a display dependent pixel format.
- makecol15_dither — Calculates a dithered 15 or 16-bit RGB value.
- makecol16 — Converts an RGB value into a display dependent pixel format.
- makecol16_dither — Calculates a dithered 15 or 16-bit RGB value.
- makecol24 — Converts an RGB value into a display dependent pixel format.
- makecol32 — Converts an RGB value into a display dependent pixel format.
- makecol8 — Converts an RGB value into a display dependent pixel format.
- makecol_depth — Converts an RGB value into the specified pixel format.
- MASK_COLOR_15 — Constant representing the mask value in sprites.
- MASK_COLOR_16 — Constant representing the mask value in sprites.
- MASK_COLOR_24 — Constant representing the mask value in sprites.
- MASK_COLOR_32 — Constant representing the mask value in sprites.
- MASK_COLOR_8 — Constant representing the mask value in sprites.
- palette_color — Maps palette indexes into the current pixel format colors.
In a truecolor video mode the red, green, and blue components for each pixel
are packed directly into the color value, rather than using a palette lookup
table. In a 15-bit mode there are 5 bits for each color, in 16-bit modes
there are 5 bits each of red and blue and six bits of green, and both 24 and
32-bit modes use 8 bits for each color (the 32-bit pixels simply have an
extra padding byte to align the data nicely). The layout of these components
can vary depending on your hardware, but will generally either be RGB or
BGR. Since the layout is not known until you select the video mode you will
be using, you must call set_gfx_mode() before using any of the following
routines!
These functions convert colors from a hardware independent form (red,
green, and blue values ranging 0-255) into various display dependent
pixel formats. Converting to 15, 16, 24, or 32-bit formats only takes a
few shifts, so it is fairly efficient. Converting to an 8-bit color
involves searching the palette to find the closest match, which is quite
slow unless you have set up an RGB mapping table (see below). Example:
/* 16 bit color version of green. */
int green_color = makecol16(0, 255, 0);
Return value:
Returns the requested RGB triplet in the specified color depth.
See also:
makeacol32,
makecol,
makecol_depth,
makecol15_dither,
rgb_map,
bestfit_color,
set_color_depth.
Examples using this:
exrgbhsv.
Converts an RGBA color into a 32-bit display pixel format, which includes
an alpha (transparency) value. There are no versions of this routine for
other color depths, because only the 32-bit format has enough room to
store a proper alpha channel. You should only use RGBA format colors as
the input to draw_trans_sprite() or draw_trans_rle_sprite() after calling
set_alpha_blender(), rather than drawing them directly to the screen.
See also:
makeacol,
set_alpha_blender,
set_write_alpha_blender.
Converts colors from a hardware independent format (red, green, and blue
values ranging 0-255) to the pixel format required by the current video
mode, calling the preceding 8, 15, 16, 24, or 32-bit makecol functions as
appropriate. Example:
/* Regardless of color depth, this will look green. */
int green_color = makecol(0, 255, 0);
Return value:
Returns the requested RGB triplet in the current color depth.
See also:
makeacol,
makecol8,
makecol_depth,
makecol15_dither,
rgb_map,
set_color_depth.
Examples using this:
Available Allegro examples.
Converts colors from a hardware independent format (red, green, and blue
values ranging 0-255) to the pixel format required by the specified color
depth. Example:
/* Compose the green color for 15 bit color depth. */
int green_15bit = makecol_depth(15, 0, 255, 0);
Return value:
Returns the requested RGB triplet in the specified color depth.
See also:
makeacol,
makecol,
makecol8,
makecol15_dither,
rgb_map,
set_color_depth.
int makeacol(int r, int g, int b, int a);
Convert RGBA colors into display dependent pixel formats. In anything
less than a 32-bit mode, these are the same as calling makecol() or
makecol_depth(), but by using these routines it is possible to create
32-bit color values that contain a true 8 bit alpha channel along with
the red, green, and blue components. You should only use RGBA format
colors as the input to draw_trans_sprite() or draw_trans_rle_sprite()
after calling set_alpha_blender(), rather than drawing them directly to
the screen.
Return value:
Returns the requested RGBA quadruplet.
See also:
makecol,
makecol_depth,
set_alpha_blender,
set_write_alpha_blender.
Examples using this:
exrotscl.
Given both a color value and a pixel coordinate, calculate a dithered 15
or 16-bit RGB value. This can produce better results when reducing images
from truecolor to hicolor. In addition to calling these functions
directly, hicolor dithering can be automatically enabled when loading
graphics by calling the set_color_conversion() function, for example
set_color_conversion(COLORCONV_REDUCE_TRUE_TO_HI | COLORCONV_DITHER).
Example:
int pixel1, pixel2;
/* The following two color values MAY be different. */
pixel1 = makecol16_dither(255, 192, 64, 0, 0);
pixel2 = makecol16_dither(255, 192, 64, 1, 0);
Return value:
Returns the RGB value dithered for the specified coordinate.
See also:
makecol,
makecol8,
set_color_conversion.
Given a color in a display dependent format, these functions extract one
of the red, green, or blue components (ranging 0-255). Example:
int r, g, b, color_value;
color_value = _getpixel15(screen, 100, 100);
r = getr15(color_value);
g = getg15(color_value);
b = getb15(color_value);
See also:
geta32,
getr,
getr_depth,
makecol,
set_color_depth.
Given a color in a 32-bit pixel format, this function extracts the alpha
component (ranging 0-255).
See also:
getr8.
Given a color in the format being used by the current video mode, these
functions extract one of the red, green, blue, or alpha components
(ranging 0-255), calling the preceding 8, 15, 16, 24, or 32-bit get
functions as appropriate. The alpha part is only meaningful for 32-bit
pixels. Example:
int r, g, b, color_value;
color_value = getpixel(screen, 100, 100);
r = getr(color_value);
g = getg(color_value);
b = getb(color_value);
See also:
getr8,
getr_depth,
makecol,
set_color_depth.
Examples using this:
exalpha.
Given a color in the format being used by the specified color depth,
these functions extract one of the red, green, blue, or alpha components
(ranging 0-255). The alpha part is only meaningful for 32-bit pixels.
Example:
int r, g, b, color_value, bpp;
bpp = bitmap_color_depth(bitmap);
color_value = getpixel(bitmap, 100, 100);
r = getr_depth(bpp, color_value);
g = getg_depth(bpp, color_value);
b = getb_depth(bpp, color_value);
See also:
getr,
getr8,
geta32,
makecol,
set_color_depth.
Examples using this:
exlights.
Table mapping palette index colors (0-255) into whatever pixel format is
being used by the current display mode. In a 256-color mode this just
maps onto the array index. In truecolor modes it looks up the specified
entry in the current palette, and converts that RGB value into the
appropriate packed pixel format. Example:
set_color_depth(32);
...
set_palette(desktop_palette);
/* Put a pixel with the color 2 (green) of the palette */
putpixel(screen, 100, 100, palette_color[2]);
See also:
set_palette,
makecol,
set_color_depth.
Examples using this:
Available Allegro examples.
Constants representing the colors used to mask transparent sprite pixels
for each color depth. In 256-color resolutions this is zero, and in
truecolor modes it is bright pink (maximum red and blue, zero green).
See also:
bitmap_mask_color,
makecol,
draw_sprite,
masked_blit.