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. | |
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.
|
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
pPalette | Pointer to an 8 bit palette to map to (768 bytes) |
uRed | Red value (0-255) |
uGreen | Green value (0-255) |
uBlue | Blue value (0-255) |
uCount | Number of colors in the palette (The array byte size is this value multiplied by 3) |
|
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
pOutput | Pointer to the output buffer. |
uInput | 15 bit RGB value in 5:5:5 format. |
|
static |
Convert 15 bit color to 24 bit color.
Given a 15 bit RGB pixel value, convert it to a 24 bit RGB triplet
pOutput | Pointer to the output buffer. |
uInput | 15 bit RGB value in 5:5:5 format. |
|
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
pOutput | Pointer to the output buffer. |
uInput | 16 bit RGB value in 1:5:5:5 format. |
|
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
pOutput | Pointer to the output buffer. |
uInput | 16 bit RGB value in 5:6:5 format. |
|
static |
Convert 16 bit color to 24 bit color.
Given a 16 bit RGB pixel value, convert it to a 24 bit RGB triplet
pOutput | Pointer to the output buffer. |
uInput | 16 bit RGB value in 5:6:5 format. |
|
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
pOutput | Pointer to an array of 256 Words |
pInput | Pointer to an array of 256 3 byte RGB triplets |
pDisplay | Display context to determine the depth and base palette |
|
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.
pOutput | Pointer to an array of 256 Words |
pInput | Pointer to the reference of the resource file |
uRezNum | Which resource ID to load |
pDisplay | Display context to determine the depth and base palette |
|
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.
pOutput | Pointer to an array of 512 bytes |
uMaskIndex | Color index to mask as invisible (0-255) or (-1) for not used |
|
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
pOutput | Pointer to an array of 256 bytes for remap table |
pInput | Pointer to an 8 bit palette (768 bytes) |
uRedAdjust | Red percentage adjust (0-1000) |
uGreenAdjust | Green percentage adjust (0-1000) |
uBlueAdjust | Blue percentage adjust (0-1000) |
|
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.
pOutput | Pointer to an array of 256 bytes |
pNewPalette | Pointer to a palette of 256 colors (768 bytes) to map to |
pOldPalette | Pointer to the palette of the shape (768 bytes) to map from |
|
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.
pOutput | Pointer to an array of 256 bytes |
pNewPalette | Pointer to a palette of 256 colors (768 bytes) to map to |
pOldPalette | Pointer to the palette of the shape (768 bytes) to map from |
|
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
pInput | Pointer to a 24 bit RGB triplet |
pDisplay | Display context to determine the depth and base palette |
|
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
uRGBColor | Value of red ((0-255)<<16) + Green ((0-255)<<8) + Blue (0-255) |
pDisplay | Display context to determine the depth and base palette |
|
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
uRed | Value of red (0-255) |
uGreen | Value of green (0-255) |
uBlue | Value of blue (0-255) |
pDisplay | Display context to determine the depth and base palette |
|
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
pInput | Pointer to a 32 bit RGBA quad |
|
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
pInput | Pointer to a 24 bit RGB triplet |
|
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
pInput | Pointer to a 32 bit RGBA quad |
|
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
pInput | Pointer to a 24 bit RGB triplet |