NvPackedColor.h File Reference

Simple abstraction for RGBA colors as parameters to various libraries/functions. More...

#include <NvFoundation.h>

Go to the source code of this file.

Defines

#define NV_PACK_COLOR_CHANNELS(r, g, b, a)   ( ( (((uint32_t)(a))&0xFF)<<24 ) | ( (((uint32_t)(b))&0xFF)<<16 ) | ( (((uint32_t)(g))&0xFF)<<8 ) | ( (((uint32_t)(r))&0xFF) ) )
 A macro to pack four color bytes into a single uint32 in proper memory order.
#define NV_PC_CHANNEL_TO_FLOAT(ch)   ( ch / 255.0f )
 A macro for mapping a single packed color channel into its floating point [0,1] rep.
#define NV_PACKED_COLOR(r, g, b, a)   NV_PACK_COLOR_CHANNELS((r),(g),(b),(a))
 A macro to build a packed color, passing in RGBA as four 8-bit integer values.
#define NV_PC_PREDEF_WHITE   NV_PACKED_COLOR(0xFF, 0xFF, 0xFF, 0xFF)
 A predefined constant for WHITE.
#define NV_PC_PREDEF_BLACK   NV_PACKED_COLOR(0x00, 0x00, 0x00, 0xFF)
 A predefined constant for BLACK.
#define NV_PC_RED(c)   ( ( c>>0 ) & 0xff )
 A macro for 'extracting' the red value from an NvPackedColor.
#define NV_PC_GREEN(c)   ( ( c>>8 ) & 0xff )
 A macro for 'extracting' the green value from an NvPackedColor.
#define NV_PC_BLUE(c)   ( ( c>>16 ) & 0xff )
 A macro for 'extracting' the blue value from an NvPackedColor.
#define NV_PC_ALPHA(c)   ( ( c>>24 ) & 0xff )
 A macro for 'extracting' the alpha value from an NvPackedColor.
#define NV_PC_RED_FLOAT(c)   ( NV_PC_RED(c)/255.0f )
 A macro for 'extracting' the red value from an NvPackedColor as a 0.
#define NV_PC_GREEN_FLOAT(c)   ( NV_PC_GREEN(c)/255.0f )
 A macro for 'extracting' the green value from an NvPackedColor as a 0.
#define NV_PC_BLUE_FLOAT(c)   ( NV_PC_BLUE(c)/255.0f )
 A macro for 'extracting' the blue value from an NvPackedColor as a 0.
#define NV_PC_ALPHA_FLOAT(c)   ( NV_PC_ALPHA(c)/255.0f )
 A macro for 'extracting' the alpha value from an NvPackedColor as a 0.
#define NV_PC_SET_ALPHA(c, a)   ( ((c)&0xFFFFFF) & ((((uint32_t)(a))&0xFF)<<24) )
 A macro for setting just the alpha value of the color, leaving the rest intact.
#define NV_PC_PACK_UINT(c)   (c)
 A macro requesting the packed color repacked into a 32-bit uint32_t.
#define NV_PC_IS_WHITE(c)   (((c)&0xFFFFFF) == 0xFFFFFF )
 A macro for testing if the base color (excluding alpha) is white.
#define NV_PC_EQUAL(x, y)   (x==y)
 A macro for testing the equality of two NvPackedColors.

Typedefs

typedef uint32_t NvPackedColor
 Main type declaration for a packed 4-color construct.


Detailed Description

Simple abstraction for RGBA colors as parameters to various libraries/functions.


Define Documentation

#define NV_PACK_COLOR_CHANNELS ( r,
g,
b,
 )     ( ( (((uint32_t)(a))&0xFF)<<24 ) | ( (((uint32_t)(b))&0xFF)<<16 ) | ( (((uint32_t)(g))&0xFF)<<8 ) | ( (((uint32_t)(r))&0xFF) ) )

A macro to pack four color bytes into a single uint32 in proper memory order.

#define NV_PACKED_COLOR ( r,
g,
b,
 )     NV_PACK_COLOR_CHANNELS((r),(g),(b),(a))

A macro to build a packed color, passing in RGBA as four 8-bit integer values.

#define NV_PC_ALPHA (  )     ( ( c>>24 ) & 0xff )

A macro for 'extracting' the alpha value from an NvPackedColor.

#define NV_PC_ALPHA_FLOAT (  )     ( NV_PC_ALPHA(c)/255.0f )

A macro for 'extracting' the alpha value from an NvPackedColor as a 0.

.1 float.

#define NV_PC_BLUE (  )     ( ( c>>16 ) & 0xff )

A macro for 'extracting' the blue value from an NvPackedColor.

#define NV_PC_BLUE_FLOAT (  )     ( NV_PC_BLUE(c)/255.0f )

A macro for 'extracting' the blue value from an NvPackedColor as a 0.

.1 float.

#define NV_PC_CHANNEL_TO_FLOAT ( ch   )     ( ch / 255.0f )

A macro for mapping a single packed color channel into its floating point [0,1] rep.

#define NV_PC_EQUAL ( x,
 )     (x==y)

A macro for testing the equality of two NvPackedColors.

#define NV_PC_GREEN (  )     ( ( c>>8 ) & 0xff )

A macro for 'extracting' the green value from an NvPackedColor.

#define NV_PC_GREEN_FLOAT (  )     ( NV_PC_GREEN(c)/255.0f )

A macro for 'extracting' the green value from an NvPackedColor as a 0.

.1 float.

#define NV_PC_IS_WHITE (  )     (((c)&0xFFFFFF) == 0xFFFFFF )

A macro for testing if the base color (excluding alpha) is white.

#define NV_PC_PACK_UINT (  )     (c)

A macro requesting the packed color repacked into a 32-bit uint32_t.

This is a no-op for the color-as-uint approach.

#define NV_PC_PREDEF_BLACK   NV_PACKED_COLOR(0x00, 0x00, 0x00, 0xFF)

A predefined constant for BLACK.

#define NV_PC_PREDEF_WHITE   NV_PACKED_COLOR(0xFF, 0xFF, 0xFF, 0xFF)

A predefined constant for WHITE.

#define NV_PC_RED (  )     ( ( c>>0 ) & 0xff )

A macro for 'extracting' the red value from an NvPackedColor.

#define NV_PC_RED_FLOAT (  )     ( NV_PC_RED(c)/255.0f )

A macro for 'extracting' the red value from an NvPackedColor as a 0.

.1 float.

#define NV_PC_SET_ALPHA ( c,
 )     ( ((c)&0xFFFFFF) & ((((uint32_t)(a))&0xFF)<<24) )

A macro for setting just the alpha value of the color, leaving the rest intact.


Typedef Documentation

typedef uint32_t NvPackedColor

Main type declaration for a packed 4-color construct.