ScummVM API documentation
Cine::Palette Class Reference

#include <pal.h>

Classes

struct  Color
 

Public Member Functions

 Palette (const Graphics::PixelFormat format=Graphics::PixelFormat(), const uint numColors=0)
 
 Palette (const Palette &other)
 
Paletteoperator= (const Palette &other)
 
Paletteclear ()
 
Paletteload (const byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors, const EndianType endian)
 
byte * save (byte *buf, const uint size, const EndianType endian) const
 
byte * save (byte *buf, const uint size, const Graphics::PixelFormat format, const EndianType endian) const
 
byte * save (byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors, const EndianType endian, const byte firstIndex=0) const
 
PaletterotateRight (byte firstIndex, byte lastIndex)
 
PaletterotateLeft (byte firstIndex, byte lastIndex)
 
PalettesaturatedAddColor (Palette &output, byte firstIndex, byte lastIndex, signed r, signed g, signed b) const
 
PalettesaturatedAddColor (Palette &output, byte firstIndex, byte lastIndex, signed rSource, signed gSource, signed bSource, const Graphics::PixelFormat &sourceFormat) const
 
PalettesaturatedAddNormalizedGray (Palette &output, byte firstIndex, byte lastIndex, signed grayDividend, signed grayDenominator) const
 
bool empty () const
 
uint colorCount () const
 
PalettefillWithBlack ()
 
bool isValid () const
 
const Graphics::PixelFormatcolorFormat () const
 
void setGlobalOSystemPalette () const
 
Color getColor (byte index) const
 
uint8 getR (byte index) const
 
uint8 getG (byte index) const
 
uint8 getB (byte index) const
 
bool ensureContrast (byte &minBrightnessColorIndex)
 
bool isEqual (byte index1, byte index2)
 

Detailed Description

A class for handling Cine-engine's palettes. TODO: Test a bit more

Constructor & Destructor Documentation

◆ Palette()

Cine::Palette::Palette ( const Graphics::PixelFormat  format = Graphics::PixelFormat(),
const uint  numColors = 0 
)

Create an initially black palette with the given color format and number of colors.

Parameters
formatColor format
numColorsNumber of colors
Note
For the default constructed object (i.e. no parameters given) this will hold: empty() && !isValid()

Member Function Documentation

◆ clear()

Palette& Cine::Palette::clear ( )

Clear the palette (Set color count to zero, release memory, overwrite color format with default value).

Note
This is very different from using fillWithBlack-function which fills the palette with black.

◆ load()

Palette& Cine::Palette::load ( const byte *  buf,
const uint  size,
const Graphics::PixelFormat  format,
const uint  numColors,
const EndianType  endian 
)

Load palette from buffer with given color format, endianness and number of colors.

Parameters
bufInput buffer
sizeInput buffer size in bytes
formatInput color format
numColorsNumber of colors to load
endianThe endianness of the colors in the input buffer

◆ save() [1/3]

byte* Cine::Palette::save ( byte *  buf,
const uint  size,
const EndianType  endian 
) const

Save the whole palette to buffer in original color format using defined endianness.

Parameters
bufOutput buffer
sizeOutput buffer size in bytes
endianThe endian type to use

◆ save() [2/3]

byte* Cine::Palette::save ( byte *  buf,
const uint  size,
const Graphics::PixelFormat  format,
const EndianType  endian 
) const

Save the whole palette to buffer in given color format using defined endianness.

Parameters
bufOutput buffer
sizeOutput buffer size in bytes
formatOutput color format
endianThe endian type to use

◆ save() [3/3]

byte* Cine::Palette::save ( byte *  buf,
const uint  size,
const Graphics::PixelFormat  format,
const uint  numColors,
const EndianType  endian,
const byte  firstIndex = 0 
) const

Save (partial) palette to buffer in given color format using defined endianness.

Parameters
bufOutput buffer
sizeOutput buffer size in bytes
formatOutput color format
numColorsNumber of colors to save
endianThe endian type to use
firstIndexStarting color index (from which onwards to save the colors)

◆ rotateRight()

Palette& Cine::Palette::rotateRight ( byte  firstIndex,
byte  lastIndex 
)

Rotate the palette in color range [firstIndex, lastIndex] to the right by one.

◆ saturatedAddColor()

Palette& Cine::Palette::saturatedAddColor ( Palette output,
byte  firstIndex,
byte  lastIndex,
signed  rSource,
signed  gSource,
signed  bSource,
const Graphics::PixelFormat sourceFormat 
) const

Saturated add an RGB color in given color format to current palette's subset and save the modified colors in the given output palette.

Parameters
outputThe output palette (Only this palette is modified)
firstIndexFirst color index of the palette's subset (Inclusive range)
lastIndexLast color index of the palette's subset (Inclusive range)
rSourceThe red color component in the source color format
gSourceThe green color component in the source color format
bSourceThe blue color component in the source color format
sourceFormatThe source color format (i.e. the color format of the given RGB color)
Note
This function basically converts the given color to the palette's internal color format and adds that using the normal saturatedAddColor-function.

◆ saturatedAddNormalizedGray()

Palette& Cine::Palette::saturatedAddNormalizedGray ( Palette output,
byte  firstIndex,
byte  lastIndex,
signed  grayDividend,
signed  grayDenominator 
) const

Saturated add a normalized gray value to current palette's subset and save the modified colors in the given output palette.

Parameters
outputThe output palette (Only this palette is modified)
firstIndexFirst color index of the palette's subset (Inclusive range)
lastIndexLast color index of the palette's subset (Inclusive range)
grayDividendDividend of the normalized gray value
grayDenominatorDenominator of the normalized gray value
Note
The normalized gray value (i.e. in range [-1, +1]) is given as a fractional number (i.e. the normalized gray value is calculated by dividing grayDividend by grayDenominator).

◆ isValid()

bool Cine::Palette::isValid ( ) const

Is the palette valid? (Mostly just checks the color format for correctness)

◆ colorFormat()

const Graphics::PixelFormat& Cine::Palette::colorFormat ( ) const

The original color format in which this palette was loaded.

◆ setGlobalOSystemPalette()

void Cine::Palette::setGlobalOSystemPalette ( ) const

Sets current palette to global OSystem's palette using g_system->getPaletteManager()->setPalette.

◆ getColor()

Color Cine::Palette::getColor ( byte  index) const

Get the color at the given palette index.

◆ getR()

uint8 Cine::Palette::getR ( byte  index) const

Get the red color component of the color at the given palette index.

◆ getG()

uint8 Cine::Palette::getG ( byte  index) const

Get the green color component of the color at the given palette index.

◆ getB()

uint8 Cine::Palette::getB ( byte  index) const

Get the blue color component of the color at the given palette index.


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