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!
int makecol8(int r, int g, int b);
int makecol15(int r, int g, int b);
int makecol16(int r, int g, int b);
int makecol24(int r, int g, int b);
int makecol32(int r, int g, int b);
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).
int makecol(int r, int g, int b);
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.
int makecol_depth(int color_depth, int r, int g, int b);
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.
int makecol15_dither(int r, int g, int b, int x, int y);
int makecol16_dither(int r, int g, int b, int x, int y);
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).
int getr8(int c);
int getg8(int c);
int getb8(int c);
int getr15(int c);
int getg15(int c);
int getb15(int c);
int getr16(int c);
int getg16(int c);
int getb16(int c);
int getr24(int c);
int getg24(int c);
int getb24(int c);
int getr32(int c);
int getg32(int c);
int getb32(int c);
Given a color in a display dependent format, these functions extract one
of the red, green, or blue components (ranging 0-255).
int getr(int c);
int getg(int c);
int getb(int c);
Given a color in the format being used by the current video mode, these
functions extract one of the red, green, or blue components (ranging
0-255), calling the preceding 8, 15, 16, 24, or 32 bit get functions as
appropriate.
int getr_depth(int color_depth, int c);
int getg_depth(int color_depth, int c);
int getb_depth(int color_depth, int c);
Given a color in the format being used by the specified color depth,
these functions extract one of the red, green, or blue components
(ranging 0-255).
extern int palette_color[256];
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.
#define MASK_COLOR_8 0
#define MASK_COLOR_15 (5.5.5 pink)
#define MASK_COLOR_16 (5.6.5 pink)
#define MASK_COLOR_24 (8.8.8 pink)
#define MASK_COLOR_32 (8.8.8 pink)
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).