Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Classes | Static Public Member Functions | List of all members
Burger::Palette Class Reference

Static functions to manage palettes. More...

Classes

struct  RGBColorList
 

Static Public Member Functions

static void FromRGB15 (RGBWord8_t *pOutput, uint_t uInput)
 Convert 15 bit color to 24 bit color.
 
static void FromRGB15 (RGBAWord8_t *pOutput, uint_t uInput)
 Convert 15 bit color to 32 bit color.
 
static void FromRGB1555 (RGBAWord8_t *pOutput, uint_t uInput)
 Convert 1:5:5:5 bit color to 32 bit color.
 
static void FromRGB16 (RGBWord8_t *pOutput, uint_t uInput)
 Convert 16 bit color to 24 bit color.
 
static void FromRGB16 (RGBAWord8_t *pOutput, uint_t uInput)
 Convert 16 bit color to 32 bit color.
 
static uint_t ToRGB15 (const RGBWord8_t *pInput)
 Convert 24 bit color to 15 bit color.
 
static uint_t ToRGB15 (const RGBAWord8_t *pInput)
 Convert 32 bit color to 15 bit color.
 
static uint_t ToRGB16 (const RGBWord8_t *pInput)
 Convert 24 bit color to 16 bit color.
 
static uint_t ToRGB16 (const RGBAWord8_t *pInput)
 Convert 32 bit color to 16 bit color.
 
static uint_t ToDisplay (const RGBWord8_t *pInput, const Display *pDisplay)
 Convert 24 bit color to current depth.
 
static uint_t ToDisplay (uint_t uRed, uint_t uGreen, uint_t uBlue, const Display *pDisplay)
 Convert 24 bit color to current depth.
 
static uint_t ToDisplay (uint32_t uRGBColor, const Display *pDisplay)
 Convert 24 bit packed color to current depth.
 
static uint_t FindColorIndex (const uint8_t *pPalette, uint_t uRed, uint_t uGreen, uint_t uBlue, uint_t uCount)
 Lookup a color in an 8 bit palette.
 
static void Make8BitLookupTable (uint_t *pOutput, const uint8_t *pInput, const Display *pDisplay)
 Convert an 8 bit palette to a true color array.
 
static void Make8BitLookupTable (uint_t *pOutput, RezFile *pInput, uint_t uRezNum, const Display *pDisplay)
 Convert an 8 bit palette to a true color array.
 
static void MakeRemapLookup (uint8_t *pOutput, const uint8_t *pNewPalette, const uint8_t *pOldPalette)
 Create an 8 bit remap table.
 
static void MakeRemapLookupMasked (uint8_t *pOutput, const uint8_t *pNewPalette, const uint8_t *pOldPalette)
 Create an 8 bit remap table.
 
static void MakeColorMasks (uint8_t *pOutput, uint_t uMaskIndex)
 Create an 8 bit mask table.
 
static void MakeFadeLookup (uint8_t *pOutput, const uint8_t *pInput, uint_t uRedAdjust, uint_t uGreenAdjust, uint_t uBlueAdjust)
 Create a remap table to brighten or darken a shape.
 

Detailed Description

Static functions to manage palettes.


This is a set of subroutines that will take a 256 color, RGB triplet palette and manage the colors within.

Member Function Documentation

◆ FindColorIndex()

uint_t BURGER_API Burger::Palette::FindColorIndex ( const uint8_t * pPalette,
uint_t uRed,
uint_t uGreen,
uint_t uBlue,
uint_t uCount )
static

Lookup a color in an 8 bit palette.


Given an 8 bit red, green and blue value, return the pixel value that is the most closest match.

The palette is an array of bytes that is sizeof(uint8_t)*uCount*3

Parameters
pPalettePointer to an 8 bit palette to map to (768 bytes)
uRedRed value (0-255)
uGreenGreen value (0-255)
uBlueBlue value (0-255)
uCountNumber of colors in the palette (The array byte size is this value multiplied by 3)
Returns
Color index that is the closest match. (0-(Count-1))
See also
ToDisplay(uint32_t,const Display *) or ToDisplay(uint_t,uint_t,uint_t,const Display *)

◆ FromRGB15() [1/2]

void BURGER_API Burger::Palette::FromRGB15 ( RGBAWord8_t * pOutput,
uint_t uInput )
static

Convert 15 bit color to 32 bit color.


Given a 15 bit RGB pixel value, convert it to a 32 bit RGB quad. Alpha will be set to 255

Parameters
pOutputPointer to the output buffer.
uInput15 bit RGB value in 5:5:5 format.
See also
FromRGB16(RGBAWord8_t *,uint_t), FromRGB15(RGBWord8_t *,uint_t), Renderer::RGB5ToRGB8Table

◆ FromRGB15() [2/2]

void BURGER_API Burger::Palette::FromRGB15 ( RGBWord8_t * pOutput,
uint_t uInput )
static

Convert 15 bit color to 24 bit color.


Given a 15 bit RGB pixel value, convert it to a 24 bit RGB triplet

Parameters
pOutputPointer to the output buffer.
uInput15 bit RGB value in 5:5:5 format.
See also
FromRGB15(RGBAWord8_t *,uint_t), FromRGB16(RGBWord8_t *,uint_t), Renderer::RGB5ToRGB8Table

◆ FromRGB1555()

void BURGER_API Burger::Palette::FromRGB1555 ( RGBAWord8_t * pOutput,
uint_t uInput )
static

Convert 1:5:5:5 bit color to 32 bit color.


Given a 1:5:5:5 bit RGB pixel value, convert it to a 32 bit RGB quad. Alpha will be set to 0 or 255

Parameters
pOutputPointer to the output buffer.
uInput16 bit RGB value in 1:5:5:5 format.
See also
FromRGB16(RGBAWord8_t *,uint_t), FromRGB15(RGBWord8_t *,uint_t), Renderer::RGB5ToRGB8Table

◆ FromRGB16() [1/2]

void BURGER_API Burger::Palette::FromRGB16 ( RGBAWord8_t * pOutput,
uint_t uInput )
static

Convert 16 bit color to 32 bit color.


Given a 16 bit RGB pixel value, convert it to a 32 bit RGB quad. Alpha will be set to 255

Parameters
pOutputPointer to the output buffer.
uInput16 bit RGB value in 5:6:5 format.
See also
FromRGB15(RGBAWord8_t *,uint_t), FromRGB16(RGBWord8_t *,uint_t), Renderer::RGB5ToRGB8Table, Renderer::RGB6ToRGB8Table

◆ FromRGB16() [2/2]

void BURGER_API Burger::Palette::FromRGB16 ( RGBWord8_t * pOutput,
uint_t uInput )
static

Convert 16 bit color to 24 bit color.


Given a 16 bit RGB pixel value, convert it to a 24 bit RGB triplet

Parameters
pOutputPointer to the output buffer.
uInput16 bit RGB value in 5:6:5 format.
See also
FromRGB15(RGBWord8_t *,uint_t), FromRGB16(RGBAWord8_t *,uint_t), Renderer::RGB5ToRGB8Table, Renderer::RGB6ToRGB8Table

◆ Make8BitLookupTable() [1/2]

void BURGER_API Burger::Palette::Make8BitLookupTable ( uint_t * pOutput,
const uint8_t * pInput,
const Display * pDisplay )
static

Convert an 8 bit palette to a true color array.


Given an 8 bit palette (256 RGB values) create a color lookup table for drawing to a screen using this palette

Parameters
pOutputPointer to an array of 256 Words
pInputPointer to an array of 256 3 byte RGB triplets
pDisplayDisplay context to determine the depth and base palette
See also
Make8BitLookupTable(uint_t *,RezFile *,uint_t,const Display *), ToDisplay(const RGBWord8_t *,const Display *)

◆ Make8BitLookupTable() [2/2]

void BURGER_API Burger::Palette::Make8BitLookupTable ( uint_t * pOutput,
Burger::RezFile * pInput,
uint_t uRezNum,
const Display * pDisplay )
static

Convert an 8 bit palette to a true color array.


Given an 8 bit palette (256 RGB values) create a 16 bit color lookup table for drawing to a screen using this palette. The palette is read in from a resource file. The resource is released on exit.

Parameters
pOutputPointer to an array of 256 Words
pInputPointer to the reference of the resource file
uRezNumWhich resource ID to load
pDisplayDisplay context to determine the depth and base palette
See also
Make8BitLookupTable(uint_t *,const uint8_t *,const Display *), ToDisplay(const RGBWord8_t *,const Display *)

◆ MakeColorMasks()

void BURGER_API Burger::Palette::MakeColorMasks ( uint8_t * pOutput,
uint_t uMaskIndex )
static

Create an 8 bit mask table.


Create a pixel mask table to make the MaskColor index transparent. This table will have the first 256 bytes containing the value to 'OR' with. The second 256 bytes will be the mask value.

What effectively occurs is that the first 256 bytes are 0-255 in that order and the last 256 bytes are 0. The mask color will have a mask of 255 and a color of zero. This is to create a table to draw masked shapes without having to incur branch penalties on processors that have problems with mispredicted branches.

Parameters
pOutputPointer to an array of 512 bytes
uMaskIndexColor index to mask as invisible (0-255) or (-1) for not used
See also
MakeRemapLookup()

◆ MakeFadeLookup()

void BURGER_API Burger::Palette::MakeFadeLookup ( uint8_t * pOutput,
const uint8_t * pInput,
uint_t uRedAdjust,
uint_t uGreenAdjust,
uint_t uBlueAdjust )
static

Create a remap table to brighten or darken a shape.


If you wish to remap an 8 bit image by altering the brightness of one or more colors, this routine will create a remap table based on the new brightness. Give the palette for the shape and pass the red, green and blue scaling adjustments in percentage points. 100 is treated as 1.0, 50 is .5 and 200 is 2.0 intensity

Parameters
pOutputPointer to an array of 256 bytes for remap table
pInputPointer to an 8 bit palette (768 bytes)
uRedAdjustRed percentage adjust (0-1000)
uGreenAdjustGreen percentage adjust (0-1000)
uBlueAdjustBlue percentage adjust (0-1000)
See also
MakeRemapLookup()

◆ MakeRemapLookup()

void BURGER_API Burger::Palette::MakeRemapLookup ( uint8_t * pOutput,
const uint8_t * pNewPalette,
const uint8_t * pOldPalette )
static

Create an 8 bit remap table.


Create a pixel data conversion table by taking the a source palette and trying to find the best match in a destination palette. The returned data will allow you to quickly color map a 256 color image onto any palette.

Parameters
pOutputPointer to an array of 256 bytes
pNewPalettePointer to a palette of 256 colors (768 bytes) to map to
pOldPalettePointer to the palette of the shape (768 bytes) to map from
See also
FindColorIndex(), MakeRemapLookupMasked()

◆ MakeRemapLookupMasked()

void BURGER_API Burger::Palette::MakeRemapLookupMasked ( uint8_t * pOutput,
const uint8_t * pNewPalette,
const uint8_t * pOldPalette )
static

Create an 8 bit remap table.


Create a pixel data conversion table by taking the a source palette and trying to find the best match in a destination palette. The returned data will allow you to quickly color map a 256 color image onto any palette.

Note
This will not alter color #0 and will not map to either color #0 or color #255. Color #255 will be remapped to an equivalent color.
Parameters
pOutputPointer to an array of 256 bytes
pNewPalettePointer to a palette of 256 colors (768 bytes) to map to
pOldPalettePointer to the palette of the shape (768 bytes) to map from
See also
FindColorIndex(), MakeRemapLookup()

◆ ToDisplay() [1/3]

uint_t BURGER_API Burger::Palette::ToDisplay ( const RGBWord8_t * pInput,
const Display * pDisplay )
static

Convert 24 bit color to current depth.


Given a 24 bit RGB triplet, convert it to a pixel value of the current depth. For 32 bit destination pixels depths, the alpha is set to 255

Note
This function can only return an 8, 15, 16, 24 or 32 bit quantity. Any other depth will force a return of 0.
Parameters
pInputPointer to a 24 bit RGB triplet
pDisplayDisplay context to determine the depth and base palette
Returns
24 bit color value as 15, 16 or 8 bit color
See also
ToRGB16(), ToRGB15(), FindColorIndex(), ToDisplay(uint_t,uint_t,uint_t,const Display *)

◆ ToDisplay() [2/3]

uint_t BURGER_API Burger::Palette::ToDisplay ( uint32_t uRGBColor,
const Display * pDisplay )
static

Convert 24 bit packed color to current depth.


Given a red/green/blue uint32_t value, convert it to a pixel value of the current depth.

If the input value has an alpha component, it's ignored

For 32 bit destinations the alpha is set to 255

Note
This function can only return an 8, 15, 16, 24 or 32 bit quantity. Any other value will force a return of 0.
Parameters
uRGBColorValue of red ((0-255)<<16) + Green ((0-255)<<8) + Blue (0-255)
pDisplayDisplay context to determine the depth and base palette
Returns
Color value as 8, 15, 16, 24 or 32 bit color
See also
ToRGB16(), ToRGB15(), FindColorIndex(), ToDisplay(uint_t,uint_t,uint_t,const Display *)

◆ ToDisplay() [3/3]

uint_t BURGER_API Burger::Palette::ToDisplay ( uint_t uRed,
uint_t uGreen,
uint_t uBlue,
const Display * pDisplay )
static

Convert 24 bit color to current depth.


Given a red, green and blue value, convert it to a pixel value of the current depth. For 32 bit destinations the alpha is set to 255

Note
This function can only return an 8, 15, 16, 24 or 32 bit quantity. Any other value will force a return of 0.
Parameters
uRedValue of red (0-255)
uGreenValue of green (0-255)
uBlueValue of blue (0-255)
pDisplayDisplay context to determine the depth and base palette
Returns
Color value as 8, 15, 16, 24 or 32 bit color
See also
ToRGB16(), ToRGB15(), FindColorIndex(), ToDisplay(uint32_t,const Display *)

◆ ToRGB15() [1/2]

uint_t Burger::Palette::ToRGB15 ( const RGBAWord8_t * pInput)
inlinestatic

Convert 32 bit color to 15 bit color.


Given a 32 bit RGBA quad stored as an array of bytes organized as Red, Green, Blue and Alpha convert it to a 15 bit RGB pixel value. Alpha is ignored

Parameters
pInputPointer to a 32 bit RGBA quad
Returns
32 bit color value as 5:5:5 color
See also
FromRGB15() or ToRGB16()

◆ ToRGB15() [2/2]

uint_t BURGER_API Burger::Palette::ToRGB15 ( const RGBWord8_t * pInput)
static

Convert 24 bit color to 15 bit color.


Given a 24 bit RGB triplet stored as an array of bytes organized as Red, Green and Blue, convert it to a 15 bit RGB pixel value

Parameters
pInputPointer to a 24 bit RGB triplet
Returns
24 bit color value as 5:5:5 color
See also
FromRGB15() or ToRGB16()

◆ ToRGB16() [1/2]

uint_t Burger::Palette::ToRGB16 ( const RGBAWord8_t * pInput)
inlinestatic

Convert 32 bit color to 16 bit color.


Given a 32 bit RGBA quad stored as an array of bytes organized as Red, Green, Blue and Alpha convert it to a 16 bit RGB pixel value. Alpha is ignored

Parameters
pInputPointer to a 32 bit RGBA quad
Returns
32 bit color value as 5:6:5 color
See also
FromRGB16() or ToRGB15()

◆ ToRGB16() [2/2]

uint_t BURGER_API Burger::Palette::ToRGB16 ( const RGBWord8_t * pInput)
static

Convert 24 bit color to 16 bit color.


Given a 24 bit RGB triplet stored as an array of bytes organized as Red, Green and Blue, convert it to a 16 bit RGB pixel value

Parameters
pInputPointer to a 24 bit RGB triplet
Returns
24 bit color value as 5:6:5 color
See also
FromRGB16() or ToRGB15()