Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

SDLmm::PixelFormat Class Reference

#include <sdlmm_pixelformat.h>

List of all members.

Public Methods

 PixelFormat (SDL_PixelFormat *pixelformat)
 Constructor from an SDL_PixelFormat*. More...

virtual ~PixelFormat ()
 The destructor. More...

Uint8 BitsPerPixel () const
Uint8 BytesPerPixel () const
Uint8 Rshift () const
Uint8 Gshift () const
Uint8 Bshift () const
Uint8 Rloss () const
Uint8 Gloss () const
Uint8 Bloss () const
Uint8 Aloss () const
Uint32 Rmask () const
Uint32 Gmask () const
Uint32 Bmask () const
Uint32 Amask () const
Color colorkey () const
Uint8 alpha () const
SDL_Palette* palette () const
Color MapRGB (Uint8 r, Uint8 g, Uint8 b) const
 Map a RGB color value to a pixel format. More...

Color MapRGB (const ColorRGB &colorrgb) const
Color MapRGBA (Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
 Map a RGBA color value to a pixel format. More...

Color MapRGBA (const ColorRGBA &colorrgba) const
void GetRGB (Color pixel, Uint8 &r, Uint8 &g, Uint8 &b) const
 Get RGB values from a pixel in the pixel format of this PixelFormat. More...

const ColorRGB GetRGB (Color pixel) const
void GetRGBA (Color pixel, Uint8 &r, Uint8 &g, Uint8 &b, Uint8 &a) const
 Get RGBA values from a pixel in the pixel format of this PixelFormat. More...

const ColorRGBA GetRGBA (Color pixel) const
Informational methods
bool valid () const
 Returns true if this PixelFormat is initialized, false otherwise. More...


Protected Attributes

SDL_PixelFormat* me
 The actual SDL_PixelFormat for this PixelFormat. More...


Detailed Description

Author:
Adam Gates

Definition at line 34 of file sdlmm_pixelformat.h.


Constructor & Destructor Documentation

SDLmm::PixelFormat::PixelFormat ( SDL_PixelFormat * pixelformat ) [inline, explicit]
 

Constructor from an SDL_PixelFormat*.

This creates a new PixelFormat object from an existing SDL_PixelFormat. It's very important not to free the original pixel format since that will cause problems. Use with caution.

Definition at line 46 of file sdlmm_pixelformat.h.

SDLmm::PixelFormat::~PixelFormat ( ) [inline, virtual]
 

The destructor.

Definition at line 49 of file sdlmm_pixelformat.h.


Member Function Documentation

Uint8 SDLmm::PixelFormat::Aloss ( ) const [inline]
 

Definition at line 68 of file sdlmm_pixelformat.h.

Uint32 SDLmm::PixelFormat::Amask ( ) const [inline]
 

Definition at line 73 of file sdlmm_pixelformat.h.

Uint8 SDLmm::PixelFormat::BitsPerPixel ( ) const [inline]
 

Definition at line 59 of file sdlmm_pixelformat.h.

Uint8 SDLmm::PixelFormat::Bloss ( ) const [inline]
 

Definition at line 67 of file sdlmm_pixelformat.h.

Uint32 SDLmm::PixelFormat::Bmask ( ) const [inline]
 

Definition at line 72 of file sdlmm_pixelformat.h.

Uint8 SDLmm::PixelFormat::Bshift ( ) const [inline]
 

Definition at line 63 of file sdlmm_pixelformat.h.

Uint8 SDLmm::PixelFormat::BytesPerPixel ( ) const [inline]
 

Definition at line 60 of file sdlmm_pixelformat.h.

const ColorRGB SDLmm::PixelFormat::GetRGB ( Color pixel ) const [inline]
 

Definition at line 144 of file sdlmm_pixelformat.h.

void SDLmm::PixelFormat::GetRGB ( Color pixel,
Uint8 & r,
Uint8 & g,
Uint8 & b ) const
 

Get RGB values from a pixel in the pixel format of this PixelFormat.

This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).

Parameters:
pixel   the pixel value
r, g, b   references to integers where the RGB result will be stored.

See also:
GetRGBA, MapRGB, MapRGBA

Definition at line 38 of file sdlmm_pixelformat.cpp.

Referenced by GetRGB().

const ColorRGBA SDLmm::PixelFormat::GetRGBA ( Color pixel ) const [inline]
 

Definition at line 167 of file sdlmm_pixelformat.h.

void SDLmm::PixelFormat::GetRGBA ( Color pixel,
Uint8 & r,
Uint8 & g,
Uint8 & b,
Uint8 & a ) const
 

Get RGBA values from a pixel in the pixel format of this PixelFormat.

This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).

Note:
If the PixelFormat has no alpha component, the alpha will be returned as 0xff (100% opaque).
Parameters:
pixel   the pixel value
r, g, b, a   references to integers where the RGBA result will be stored.
See also:
GetRGB, MapRGB, MapRGBA

Definition at line 42 of file sdlmm_pixelformat.cpp.

Referenced by GetRGBA().

Uint8 SDLmm::PixelFormat::Gloss ( ) const [inline]
 

Definition at line 66 of file sdlmm_pixelformat.h.

Uint32 SDLmm::PixelFormat::Gmask ( ) const [inline]
 

Definition at line 71 of file sdlmm_pixelformat.h.

Uint8 SDLmm::PixelFormat::Gshift ( ) const [inline]
 

Definition at line 62 of file sdlmm_pixelformat.h.

Color SDLmm::PixelFormat::MapRGB ( const ColorRGB & colorrgb ) const [inline]
 

Definition at line 102 of file sdlmm_pixelformat.h.

Color SDLmm::PixelFormat::MapRGB ( Uint8 r,
Uint8 g,
Uint8 b ) const
 

Map a RGB color value to a pixel format.

Maps the RGB color value to this PixelFormat's pixel format and returns the pixel value as a 32-bit int.

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

Returns:
A pixel value best approximating the given RGB color value for a given pixel format. If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).
Parameters:
r, g, b   the RGB values.
See also:
GetRGB, GetRGBA, MapRGBA

Definition at line 30 of file sdlmm_pixelformat.cpp.

Referenced by MapRGB().

Color SDLmm::PixelFormat::MapRGBA ( const ColorRGBA & colorrgba ) const [inline]
 

Definition at line 127 of file sdlmm_pixelformat.h.

Color SDLmm::PixelFormat::MapRGBA ( Uint8 r,
Uint8 g,
Uint8 b,
Uint8 a ) const
 

Map a RGBA color value to a pixel format.

Maps the RGBA color value to this PixelFormat's pixel format and returns the pixel value as a 32-bit int.

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

If the specified pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette).

Returns:
A pixel value best approximating the given RGBA color value for a given pixel format. If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).
Parameters:
r, g, b, a   the RGBA values.
See also:
GetRGB, GetRGBA, MapRGB

Definition at line 34 of file sdlmm_pixelformat.cpp.

Referenced by MapRGBA().

Uint8 SDLmm::PixelFormat::Rloss ( ) const [inline]
 

Definition at line 65 of file sdlmm_pixelformat.h.

Uint32 SDLmm::PixelFormat::Rmask ( ) const [inline]
 

Definition at line 70 of file sdlmm_pixelformat.h.

Uint8 SDLmm::PixelFormat::Rshift ( ) const [inline]
 

Definition at line 61 of file sdlmm_pixelformat.h.

Uint8 SDLmm::PixelFormat::alpha ( ) const [inline]
 

Definition at line 76 of file sdlmm_pixelformat.h.

Color SDLmm::PixelFormat::colorkey ( ) const [inline]
 

Definition at line 75 of file sdlmm_pixelformat.h.

SDL_Palette * SDLmm::PixelFormat::palette ( ) const [inline]
 

Definition at line 77 of file sdlmm_pixelformat.h.

bool SDLmm::PixelFormat::valid ( ) const [inline]
 

Returns true if this PixelFormat is initialized, false otherwise.

Warning:
Using an uninitialzied PixelFormat can cause many problems.

Definition at line 56 of file sdlmm_pixelformat.h.


Member Data Documentation

SDL_PixelFormat * SDLmm::PixelFormat::me [protected]
 

The actual SDL_PixelFormat for this PixelFormat.

Definition at line 37 of file sdlmm_pixelformat.h.


The documentation for this class was generated from the following files:
Documentation automatically generated by doxygen written by Dimitri van Heesch. Project hosted at
Hosted by SourceForge