ScummVM API documentation
Graphics::Palette Class Reference

Simple class for handling a palette data. More...

#include <palette.h>

Inheritance diagram for Graphics::Palette:
Dgds::DgdsPal Ultima::Ultima8::Palette

Public Member Functions

 Palette (uint size)
 Construct a new Palette object. More...
 
 Palette (const byte *data, uint size)
 Construct a new Palette object. More...
 
 Palette (const Palette &p)
 
Paletteoperator= (const Palette &rhs)
 
bool operator== (const Palette &rhs) const
 
bool operator!= (const Palette &rhs) const
 
bool equals (const Palette &p) const
 
bool contains (const Palette &p) const
 
const byte * data () const
 
uint size () const
 
void set (uint entry, byte r, byte g, byte b)
 
void get (uint entry, byte &r, byte &g, byte &b) const
 
uint find (byte r, byte g, byte b) const
 
byte findBestColor (byte r, byte g, byte b, bool useNaiveAlg=false) const
 
void clear ()
 
void set (const byte *colors, uint start, uint num)
 
void set (const Palette &p, uint start, uint num)
 
void grab (byte *colors, uint start, uint num) const
 
void grab (Palette &p, uint start, uint num) const
 

Static Public Member Functions

static Palette createEGAPalette ()
 

Static Public Attributes

static const uint16 npos = 0xFFFF
 

Detailed Description

Simple class for handling a palette data.

The palette data is specified in interleaved RGB format. That is, the first byte of the memory block 'colors' points at is the red component of the first new color; the second byte the green component of the first new color; the third byte the blue component, the last byte to the alpha (transparency) value. Then the second color starts, and so on. So memory looks like this: R1-G1-B1-R2-G2-B2-R3-...

Constructor & Destructor Documentation

◆ Palette() [1/2]

Graphics::Palette::Palette ( uint  size)

Construct a new Palette object.

Parameters
sizethe number of palette entries

◆ Palette() [2/2]

Graphics::Palette::Palette ( const byte *  data,
uint  size 
)

Construct a new Palette object.

Parameters
datathe palette data, in interleaved RGB format
sizethe number of palette entries

Member Function Documentation

◆ createEGAPalette()

static Palette Graphics::Palette::createEGAPalette ( )
static

Constructs a new palette containing the standarad EGA palette

◆ find()

uint Graphics::Palette::find ( byte  r,
byte  g,
byte  b 
) const
inline

Finds the index of an exact color from the palette.

Returns
the palette index or npos if not found

◆ findBestColor()

byte Graphics::Palette::findBestColor ( byte  r,
byte  g,
byte  b,
bool  useNaiveAlg = false 
) const

Finds the index of the closest color from the palette.

Parameters
useNaiveAlgif true, use a simpler algorithm
Returns
the palette index

◆ set()

void Graphics::Palette::set ( const byte *  colors,
uint  start,
uint  num 
)

Replace the specified range of the palette with new colors. The palette entries from 'start' till (start+num-1) will be replaced - so a full palette update is accomplished via start=0, num=256.

Parameters
colorsthe new palette data, in interleaved RGB format
startthe first palette entry to be updated
numthe number of palette entries to be updated
Note
It is an error if start+num exceeds 256.

◆ grab()

void Graphics::Palette::grab ( byte *  colors,
uint  start,
uint  num 
) const

Grabs a specified part of the currently active palette. The format is the same as for setPalette.

Parameters
colorsthe palette data, in interleaved RGB format
startthe first platte entry to be read
numthe number of palette entries to be read
Note
It is an error if start+num exceeds 256.

The documentation for this class was generated from the following file: