CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
palette Class Reference

8bpp palette class. More...

#include <th_gfx_sdl.h>

Public Member Functions

 palette ()=default
 Create an empty palette. All entries are black and fully opaque.
 
 palette (const uint8_t *pData, size_t iDataLength, bool is8bit)
 Load a 256 index color palette from the supplied data.
 
bool set_entry (int iEntry, uint8_t iR, uint8_t iG, uint8_t iB)
 Set an entry of the palette.
 
const std::array< argb_colour, color_count > & get_argb_data () const
 Get the internal palette data for fast (read-only) access.
 
void set_argb (int iEntry, uint32_t iVal)
 Set an entry of the palette.
 

Static Public Member Functions

static constexpr argb_colour pack_argb (uint8_t iA, uint8_t iR, uint8_t iG, uint8_t iB)
 Convert A, R, G, B values to a 32bpp colour.
 
static constexpr uint8_t get_red (argb_colour iColour)
 Get the red component of a colour.
 
static constexpr uint8_t get_green (argb_colour iColour)
 Get the green component of a colour.
 
static constexpr uint8_t get_blue (argb_colour iColour)
 Get the blue component of a colour.
 
static constexpr uint8_t get_alpha (argb_colour iColour)
 Get the opacity component of a colour.
 

Static Public Attributes

static constexpr int color_count {256}
 Number of colours in the palette.
 

Detailed Description

8bpp palette class.

Constructor & Destructor Documentation

◆ palette() [1/2]

palette::palette ( )
default

Create an empty palette. All entries are black and fully opaque.

◆ palette() [2/2]

palette::palette ( const uint8_t *  pData,
size_t  iDataLength,
bool  is8bit 
)

Load a 256 index color palette from the supplied data.

Parameters
pDataPalette data in RGB or RGBA format.
iDataLengthSize of the data.
is8bitWhether the data is in 8bpp (otherwise 6bpp).
Returns
Whether loading of the palette succeeded.

Member Function Documentation

◆ get_alpha()

static constexpr uint8_t palette::get_alpha ( argb_colour  iColour)
inlinestaticconstexpr

Get the opacity component of a colour.

Parameters
iColourColour to examine.
Returns
The opacity of the colour.

◆ get_argb_data()

const std::array< argb_colour, palette::color_count > & palette::get_argb_data ( ) const

Get the internal palette data for fast (read-only) access.

Returns
Table with all 256 colours of the palette.

◆ get_blue()

static constexpr uint8_t palette::get_blue ( argb_colour  iColour)
inlinestaticconstexpr

Get the blue component of a colour.

Parameters
iColourColour to examine.
Returns
The blue component intensity of the colour.

◆ get_green()

static constexpr uint8_t palette::get_green ( argb_colour  iColour)
inlinestaticconstexpr

Get the green component of a colour.

Parameters
iColourColour to examine.
Returns
The green component intensity of the colour.

◆ get_red()

static constexpr uint8_t palette::get_red ( argb_colour  iColour)
inlinestaticconstexpr

Get the red component of a colour.

Parameters
iColourColour to examine.
Returns
The red component intensity of the colour.

◆ pack_argb()

static constexpr argb_colour palette::pack_argb ( uint8_t  iA,
uint8_t  iR,
uint8_t  iG,
uint8_t  iB 
)
inlinestaticconstexpr

Convert A, R, G, B values to a 32bpp colour.

Parameters
iAAmount of opacity (0-255).
iRAmount of red (0-255).
iGAmount of green (0-255).
iBAmount of blue (0-255).
Returns
32bpp value representing the provided colour values.

◆ set_argb()

void palette::set_argb ( int  iEntry,
uint32_t  iVal 
)
inline

Set an entry of the palette.

Parameters
iEntryEntry to modify.
iValPalette value to set.

◆ set_entry()

bool palette::set_entry ( int  iEntry,
uint8_t  iR,
uint8_t  iG,
uint8_t  iB 
)

Set an entry of the palette.

The RGB colour (255, 0, 255) is used as the transparent colour.

Parameters
iEntryEntry number to change.
iRAmount of red in the new entry.
iGAmount of green in the new entry.
iBAmount of blue in the new entry.
Returns
Setting the entry succeeded.

Member Data Documentation

◆ color_count

constexpr int palette::color_count {256}
staticconstexpr

Number of colours in the palette.


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