class::hal::DisplayPalette

class hal::DisplayPalette
  : public api::InfoObject

A display palette is used to map bitmap colors to an actual display. The Stratify graphics library supports the following formats.

  • 1bpp (1 bit per pixel)
  • 2bpp
  • 4bpp
  • 8bpp

This class is used to manage how the pixel maps to the display. For example, if the graphics use 4bpp and the display uses RGB565, the palette would have 16 entries that contain RGB565 values and define how a color in the 4bpp format maps to a color on the display.

Summary

DisplayPalette()

DisplayPalette(

const display_palette_t & palette,
bool readonly
)

int allocate_colors(

int count,
int pixel_size
)

u16 bits_per_pixel() const

var::Data & colors()

const var::Data & colors() const

u8 count() const

int load(

const arg::SourceFilePath & path
)

u8 pixel_format() const

int save(

const arg::DestinationFilePath & path
) const

void set_color(

u32 v,
u8 r,
u8 g,
u8 b
)

void set_colors(

void * v,
int count,
int pixel_size,
bool readonly
)

int set_monochrome()

void set_pixel_format(

int v
)

static void set_color(

display_palette_pixel_format_rgb444_t & pixel,
u8 r,
u8 g,
u8 b,
u8 offset
)

static void set_color(

display_palette_pixel_format_rgb565_t & pixel,
u8 r,
u8 g,
u8 b
)

static void set_color(

display_palette_pixel_format_rgb666_t & pixel,
u8 r,
u8 g,
u8 b
)

static void set_color(

display_palette_pixel_format_rgb888_t & pixel,
u8 r,
u8 g,
u8 b
)

enum @7

Members

DisplayPalette()

DisplayPalette(

const display_palette_t & palette,
bool readonly
)


int allocate_colors(

int count,
int pixel_size
)

Allocates memory for count colors with pixel_size bytes each.

Parameters

  • count The total number of colors

  • pixel_size The number of bytes occupied by each color

Returns

Less than zero if there were an error allocating memory


u16 bits_per_pixel() const

var::Data & colors()

const var::Data & colors() const

u8 count() const

Returns the number of colors in the palette.


int load(

const arg::SourceFilePath & path
)


u8 pixel_format() const

Returns the pixel format.


int save(

const arg::DestinationFilePath & path
) const


void set_color(

u32 v,
u8 r,
u8 g,
u8 b
)

Sets the color.

Parameters

  • v The color index

  • r The red component

  • g The green component

  • b The blue component

The color format is converted based on the value of pixel_format(). For example, if pixel_format() returns PIXEL_FORMAT_RGB565, the color will be set in the palette to match that format.


void set_colors(

void * v,
int count,
int pixel_size,
bool readonly
)


int set_monochrome()

void set_pixel_format(

int v
)


static void set_color(

display_palette_pixel_format_rgb444_t & pixel,
u8 r,
u8 g,
u8 b,
u8 offset
)


static void set_color(

display_palette_pixel_format_rgb565_t & pixel,
u8 r,
u8 g,
u8 b
)


static void set_color(

display_palette_pixel_format_rgb666_t & pixel,
u8 r,
u8 g,
u8 b
)


static void set_color(

display_palette_pixel_format_rgb888_t & pixel,
u8 r,
u8 g,
u8 b
)


enum @7
  • PIXEL_FORMAT_1BPP
  • PIXEL_FORMAT_RGB444
  • PIXEL_FORMAT_RGB565
  • PIXEL_FORMAT_RGB666
  • PIXEL_FORMAT_RGB888

X

Thanks for Coming!

Subscribe to news and updates