roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
roo_display::Palette Class Reference

Palette storage for IndexedN color modes. More...

#include <color_mode_indexed.h>

Public Member Functions

 Palette ()
 Create a dummy palette with a single transparent color.
 
const Colorcolors () const
 Return pointer to the color table.
 
int size () const
 Return palette size.
 
Color getColorAt (int idx) const
 Return the idx-th color.
 
TransparencyMode transparency_mode () const
 Return palette transparency mode.
 
uint8_t getIndexOfColor (Color color)
 Return the index of a specified color.
 

Static Public Member Functions

static Palette ReadOnly (const Color *colors, int size)
 Create a read-only palette backed by the given colors.
 
static Palette ReadOnly (const Color *colors, int size, TransparencyMode transparency_mode)
 Read-only palette with explicit transparency mode.
 
static Palette ReadWrite (const Color *colors, int size)
 Create a read/write palette backed by the given colors.
 
static Palette ReadWrite (const Color *colors, int size, TransparencyMode transparency_mode)
 Read/write palette with explicit transparency mode.
 
static Palette Dynamic (int max_size)
 Create a dynamic palette for drawing to offscreens.
 

Detailed Description

Palette storage for IndexedN color modes.

Definition at line 75 of file color_mode_indexed.h.

Constructor & Destructor Documentation

◆ Palette()

roo_display::Palette::Palette ( )

Create a dummy palette with a single transparent color.

Definition at line 26 of file color_mode_indexed.cpp.

Referenced by Dynamic(), ReadOnly(), ReadOnly(), and ReadWrite().

Member Function Documentation

◆ colors()

const Color * roo_display::Palette::colors ( ) const
inline

Return pointer to the color table.

Definition at line 129 of file color_mode_indexed.h.

Referenced by ReadOnly(), ReadOnly(), ReadWrite(), and ReadWrite().

◆ Dynamic()

Palette roo_display::Palette::Dynamic ( int  max_size)
static

Create a dynamic palette for drawing to offscreens.

Colors are added up to max_size. After that, missing colors map to index 0.

Parameters
max_sizeMaximum number of colors to store.
Returns
Dynamic palette instance.

Definition at line 51 of file color_mode_indexed.cpp.

References roo_display::kNone, Palette(), palette, and size().

◆ getColorAt()

Color roo_display::Palette::getColorAt ( int  idx) const
inline

Return the idx-th color.

Definition at line 135 of file color_mode_indexed.h.

◆ getIndexOfColor()

uint8_t roo_display::Palette::getIndexOfColor ( Color  color)

Return the index of a specified color.

Not valid for read-only palettes. For dynamic palettes, missing colors are added up to max_size; otherwise returns 0 when not found.

Definition at line 62 of file color_mode_indexed.cpp.

References color, roo_display::kCrude, roo_display::kFull, and roo_display::kNone.

◆ ReadOnly() [1/2]

Palette roo_display::Palette::ReadOnly ( const Color colors,
int  size 
)
static

Create a read-only palette backed by the given colors.

The color array is not copied and must remain valid. Read-only palettes cannot be used for inverse lookup (ARGB -> index); use ReadWrite() or Dynamic() for that. Transparency is auto-detected.

Parameters
colorsPalette colors (array must outlive the palette).
sizeNumber of colors in the palette.
Returns
Read-only palette instance.

Definition at line 29 of file color_mode_indexed.cpp.

References colors(), Palette(), and size().

◆ ReadOnly() [2/2]

Palette roo_display::Palette::ReadOnly ( const Color colors,
int  size,
TransparencyMode  transparency_mode 
)
static

Read-only palette with explicit transparency mode.

Parameters
colorsPalette colors (array must outlive the palette).
sizeNumber of colors in the palette.
transparency_modeExplicit transparency mode to use.
Returns
Read-only palette instance.

Definition at line 34 of file color_mode_indexed.cpp.

References colors(), Palette(), size(), and transparency_mode().

◆ ReadWrite() [1/2]

Palette roo_display::Palette::ReadWrite ( const Color colors,
int  size 
)
static

Create a read/write palette backed by the given colors.

Enables inverse lookup (ARGB -> index), e.g. for Offscreen. The array is not copied and must remain valid. Transparency is auto-detected.

Parameters
colorsPalette colors (array must outlive the palette).
sizeNumber of colors in the palette.
Returns
Read/write palette instance.

Definition at line 39 of file color_mode_indexed.cpp.

References colors(), ReadWrite(), and size().

Referenced by ReadWrite().

◆ ReadWrite() [2/2]

Palette roo_display::Palette::ReadWrite ( const Color colors,
int  size,
TransparencyMode  transparency_mode 
)
static

Read/write palette with explicit transparency mode.

Parameters
colorsPalette colors (array must outlive the palette).
sizeNumber of colors in the palette.
transparency_modeExplicit transparency mode to use.
Returns
Read/write palette instance.

Definition at line 44 of file color_mode_indexed.cpp.

References colors(), Palette(), size(), and transparency_mode().

◆ size()

int roo_display::Palette::size ( ) const
inline

Return palette size.

Definition at line 132 of file color_mode_indexed.h.

Referenced by Dynamic(), ReadOnly(), ReadOnly(), ReadWrite(), and ReadWrite().

◆ transparency_mode()

TransparencyMode roo_display::Palette::transparency_mode ( ) const
inline

Return palette transparency mode.

Definition at line 138 of file color_mode_indexed.h.

Referenced by ReadOnly(), and ReadWrite().


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