All the Allegro drawing functions use integer parameters to represent colors. In truecolor resolutions these numbers encode the color directly as a collection of red, green, and blue bits, but in a regular 256-color mode the values are treated as indexes into the current palette, which is a table listing the red, green and blue intensities for each of the 256 possible colors.
Palette entries are stored in an RGB structure, which contains red, green and blue intensities in the VGA hardware format, ranging from 0-63, and is defined as:
It contains an additional field for the purpose of padding but you should not usually care about it. For example:typedef struct RGB { unsigned char r, g, b; } RGB;
The type PALETTE is defined to be an array of PAL_SIZE RGB structures, where PAL_SIZE is a preprocessor constant equal to 256.RGB black = { 0, 0, 0 }; RGB white = { 63, 63, 63 }; RGB green = { 0, 63, 0 }; RGB grey = { 32, 32, 32 };
You may notice that a lot of the code in Allegro spells 'palette' as 'pallete'. This is because the headers from my old Mark Williams compiler on the Atari spelt it with two l's, so that is what I'm used to. Allegro will happily accept either spelling, due to some #defines in allegro/alcompat.h (which can be turned off by defining the ALLEGRO_NO_COMPATIBILITY symbol before including Allegro headers).
RGB rgb; ... vsync(); set_color(192, &rgb);
See also: set_palette, get_color, _set_color.
Examples using this: ex12bit, exrgbhsv, exscroll.
If you really must use _set_color from retrace_proc, note that it should only be used under DOS, in VGA mode 13h and mode-X. Some SVGA chipsets aren't VGA compatible (set_color() and set_palette() will use VESA calls on these cards, but _set_color() doesn't know about that).
See also: set_color, set_gfx_mode.
Examples using this: ex3buf.
BITMAP *bmp; PALETTE palette; ... bmp = load_bitmap(filename, palette); if (!bmp) abort_on_error("Couldn't load bitmap!"); set_palette(palette);
See also: set_gfx_mode, set_palette_range, set_color, get_palette, select_palette, palette_color.
Examples using this: Available Allegro examples.
PALETTE palette; ... /* Modify the first 16 entries. */ change_first_16_colors(palette); /* Now update them waiting for vsync. */ set_palette_range(palette, 0, 15, 1);
See also: set_palette, get_palette_range.
Examples using this: exzbuf.
RGB color; ... get_color(11, &color);
See also: get_palette, set_color.
PALETTE pal; ... get_palette(pal);
See also: get_palette_range, get_color, set_palette.
See also: get_palette, set_palette_range.
See also: fade_in, fade_out, fade_from.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_from.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_in.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_out.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_in, fade_out, fade_interpolate, fade_from_range.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_out, fade_from, fade_interpolate, fade_in_range.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_in, fade_from, fade_interpolate, fade_in_range.
Examples using this: ex12bit.
See also: set_palette, unselect_palette.
Examples using this: exlights.
See also: select_palette.
See also: generate_optimized_palette, set_color_depth.
Examples using this: excolmap, exrgbhsv, extruec, exupdate.
Return value: Returns the number of different colors recognised in the provided bitmap, zero if the bitmap is not a truecolor image or there wasn't enough memory to perform the operation, and negative if there was any internal error in the color reduction code.
See also: generate_332_palette, set_color_depth.
See also: black_palette, desktop_palette.
Examples using this: exjoy.
See also: default_palette, desktop_palette.
Examples using this: expal.
The contents of this palette are 16 colors repeated 16 times. Color entry zero is equal to color entry 16, which is equal to color entry 24, etc.
Index Color RGB values 0 White 63 63 63 1 Red 63 0 0 2 Green 0 63 0 3 Yellow 63 63 0 4 Blue 0 0 63 5 Pink 63 0 63 6 Cyan 0 63 63 7 Grey 16 16 16 8 Light grey 31 31 31 9 Light red 63 31 31 10 Light green 31 63 31 11 Light yellow 63 63 31 12 Light blue 31 31 63 13 Light pink 63 31 63 14 Light cyan 31 63 63 15 Black 0 0 0
See also: default_palette, black_palette.
Examples using this: Available Allegro examples.