OpenXcom
1.0
Open-source clone of the original X-Com
|
Container for palettes (sets of 8bpp colors). More...
#include <Palette.h>
Public Member Functions | |
Palette () | |
Creates a blank palette. More... | |
~Palette () | |
Cleans up the palette. More... | |
void | loadDat (const std::string &filename, int ncolors, int offset=0) |
Loads the colors from an X-Com palette. More... | |
SDL_Color * | getColors (int offset=0) const |
Provides access to colors contained in the palette. More... | |
Static Public Member Functions | |
static Uint32 | getRGBA (SDL_Color *pal, Uint8 color) |
Converts a given color into a RGBA color value. More... | |
static int | palOffset (int palette) |
Gets the position of a given palette. More... | |
static Uint8 | blockOffset (Uint8 block) |
Gets the position of a certain color block in a palette. More... | |
Static Public Attributes | |
static const int | backPos = 224 |
Position of the background colors block in an X-Com palette (used for background images in screens). | |
Container for palettes (sets of 8bpp colors).
Works as an encapsulation for SDL's SDL_Color struct and provides shortcuts for common tasks to make code more readable.
OpenXcom::Palette::Palette | ( | ) |
Creates a blank palette.
Initializes a brand new palette.
OpenXcom::Palette::~Palette | ( | ) |
Cleans up the palette.
Deletes any colors contained within.
|
inlinestatic |
Gets the position of a certain color block in a palette.
Returns the position of a certain color block in an X-Com palette (they're usually split in 16-color gradients). Makes setting element colors a lot easier than determining the exact color position.
block | Requested block. |
SDL_Color * OpenXcom::Palette::getColors | ( | int | offset = 0 | ) | const |
Provides access to colors contained in the palette.
offset | Offset to a specific color. |
|
static |
Converts a given color into a RGBA color value.
Converts an SDL_Color struct into an hexadecimal RGBA color value.
Mostly used for operations with SDL_gfx that require colors in this format.
pal | Requested palette. |
color | Requested color in the palette. |
void OpenXcom::Palette::loadDat | ( | const std::string & | filename, |
int | ncolors, | ||
int | offset = 0 |
||
) |
Loads the colors from an X-Com palette.
Loads an X-Com palette from a file.
X-Com palettes are just a set of RGB colors in a row, on a 0-63 scale, which have to be adjusted for modern computers (0-255 scale).
filename | Filename of the palette. |
ncolors | Number of colors in the palette. |
offset | Position of the palette in the file (in bytes). |
|
inlinestatic |
Gets the position of a given palette.
Returns the position of a palette inside an X-Com palette file (each is a 768-byte chunks). Handy for loading the palettes from the game files.
palette | Requested palette. |