ScummVM API documentation
Graphics::PixelFormat Struct Reference

#include <pixelformat.h>

Public Member Functions

constexpr PixelFormat ()
 
constexpr PixelFormat (byte BytesPerPixel, byte RBits, byte GBits, byte BBits, byte ABits, byte RShift, byte GShift, byte BShift, byte AShift)
 
bool operator== (const PixelFormat &fmt) const
 
bool operator!= (const PixelFormat &fmt) const
 
uint32 RGBToColor (uint8 r, uint8 g, uint8 b) const
 
template<class T >
uint32 RGBToColorT (uint8 r, uint8 g, uint8 b) const
 
uint32 ARGBToColor (uint8 a, uint8 r, uint8 g, uint8 b) const
 
template<class T >
uint32 ARGBToColorT (uint8 a, uint8 r, uint8 g, uint8 b) const
 
void colorToRGB (uint32 color, uint8 &r, uint8 &g, uint8 &b) const
 
template<class T >
void colorToRGBT (uint32 color, uint8 &r, uint8 &g, uint8 &b) const
 
void colorToARGB (uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) const
 
template<class T >
void colorToARGBT (uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) const
 
Common::String toString () const
 
bool isCLUT8 () const
 
template<>
uint32 RGBToColorT (uint8 r, uint8 g, uint8 b) const
 
template<>
uint32 ARGBToColorT (uint8 a, uint8 r, uint8 g, uint8 b) const
 
template<>
void colorToRGBT (uint32 color, uint8 &r, uint8 &g, uint8 &b) const
 
template<>
void colorToARGBT (uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) const
 
Convenience functions for getting the number of color component bits
byte rBits () const
 
byte gBits () const
 
byte bBits () const
 
byte aBits () const
 
byte bpp () const
 
Convenience functions for getting color components' maximum values
uint rMax () const
 
uint gMax () const
 
uint bMax () const
 
uint aMax () const
 

Static Public Member Functions

static PixelFormat createFormatCLUT8 ()
 
static uint expand (uint bits, uint color)
 

Public Attributes

byte bytesPerPixel
 
byte rLoss
 
byte gLoss
 
byte bLoss
 
byte aLoss
 
byte rShift
 
byte gShift
 
byte bShift
 
byte aShift
 

Detailed Description

Pixel format description.

Like ColorMasks, it includes the given values to create colors from RGB values and to retrieve RGB values from colors.

Unlike ColorMasks, it is not dependent on knowing the exact pixel format on compile time.

A minor difference between ColorMasks and PixelFormat is that ColorMasks stores the bit count per channel in kFooBits, while PixelFormat stores the loss compared to 8 bits per channel in #Loss. It also does not contain mask values.

Constructor & Destructor Documentation

◆ PixelFormat() [1/2]

constexpr Graphics::PixelFormat::PixelFormat ( )
inline

Default constructor that creates a null pixel format.

◆ PixelFormat() [2/2]

constexpr Graphics::PixelFormat::PixelFormat ( byte  BytesPerPixel,
byte  RBits,
byte  GBits,
byte  BBits,
byte  ABits,
byte  RShift,
byte  GShift,
byte  BShift,
byte  AShift 
)
inline

Construct a pixel format based on the provided arguments.

Examples:

  • RGBA8888:
    BytesPerPixel = 4, RBits = GBits = BBits = ABits = 8, RShift = 24, GShift = 16, BShift = 8, AShift = 0
  • ABGR8888:
    BytesPerPixel = 4, RBits = GBits = BBits = ABits = 8, RShift = 0, GShift = 8, BShift = 16, AShift = 24
  • RGB565:
    BytesPerPixel = 2, RBits = 5, GBits = 6, BBits = 5, ABits = 0, RShift = 11, GShift = 5, BShift = 0, AShift = 0

Member Function Documentation

◆ createFormatCLUT8()

static PixelFormat Graphics::PixelFormat::createFormatCLUT8 ( )
inlinestatic

Define a CLUT8 pixel format.

◆ operator==()

bool Graphics::PixelFormat::operator== ( const PixelFormat fmt) const
inline

Check if two pixel formats are the same

◆ operator!=()

bool Graphics::PixelFormat::operator!= ( const PixelFormat fmt) const
inline

Check if two pixel formats are different.

◆ RGBToColor()

uint32 Graphics::PixelFormat::RGBToColor ( uint8  r,
uint8  g,
uint8  b 
) const
inline

Return an RGB color value from red, green, and blue values.

◆ ARGBToColor()

uint32 Graphics::PixelFormat::ARGBToColor ( uint8  a,
uint8  r,
uint8  g,
uint8  b 
) const
inline

Return an ARGB color value from alpha, red, green, and blue values.

◆ colorToRGB()

void Graphics::PixelFormat::colorToRGB ( uint32  color,
uint8 &  r,
uint8 &  g,
uint8 &  b 
) const
inline

Retrieve red, green, and blue values from an RGB color value.

◆ colorToARGB()

void Graphics::PixelFormat::colorToARGB ( uint32  color,
uint8 &  a,
uint8 &  r,
uint8 &  g,
uint8 &  b 
) const
inline

Retrieve alpha, red, green, and blue values from an ARGB color value.

◆ rBits()

byte Graphics::PixelFormat::rBits ( ) const
inline

Return the number of red component bits.

◆ gBits()

byte Graphics::PixelFormat::gBits ( ) const
inline

Return the number of green component bits.

◆ bBits()

byte Graphics::PixelFormat::bBits ( ) const
inline

Return the number of blue component bits.

◆ aBits()

byte Graphics::PixelFormat::aBits ( ) const
inline

Return the number of alpha component bits.

◆ bpp()

byte Graphics::PixelFormat::bpp ( ) const
inline

Return the total number of bits for the pixel format.

◆ rMax()

uint Graphics::PixelFormat::rMax ( ) const
inline

Return the maximum value of red.

◆ gMax()

uint Graphics::PixelFormat::gMax ( ) const
inline

Return the maximum value of green.

◆ bMax()

uint Graphics::PixelFormat::bMax ( ) const
inline

Return the maximum value of blue.

◆ aMax()

uint Graphics::PixelFormat::aMax ( ) const
inline

Return the maximum value of alpha.

◆ expand()

static uint Graphics::PixelFormat::expand ( uint  bits,
uint  color 
)
inlinestatic

Expand a given bit-depth component to a full 8-bit component.

◆ toString()

Common::String Graphics::PixelFormat::toString ( ) const

Return string representation.

◆ isCLUT8()

bool Graphics::PixelFormat::isCLUT8 ( ) const
inline

Shortcut method for checking if the current format is CLUT8 or not

Member Data Documentation

◆ bytesPerPixel

byte Graphics::PixelFormat::bytesPerPixel

Number of bytes used in the pixel format.

◆ aLoss

byte Graphics::PixelFormat::aLoss

Precision loss of each color component.

◆ aShift

byte Graphics::PixelFormat::aShift

Binary left shift of each color component in the pixel value.


The documentation for this struct was generated from the following file: