All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Luminous::PixelFormat Class Reference

Describes the pixel format of an image. More...

#include <Luminous/PixelFormat.hpp>

Public Types

enum  ChannelLayout {
  LAYOUT_UNKNOWN, LAYOUT_ALPHA = GL_ALPHA, LAYOUT_RGB = GL_RGB, LAYOUT_RGBA = GL_RGBA,
  LAYOUT_RED_GREEN = GL_RG, LAYOUT_STENCIL_INDEX = GL_STENCIL_INDEX, LAYOUT_DEPTH_COMPONENT = GL_DEPTH_COMPONENT, LAYOUT_RED = GL_RED,
  LAYOUT_GREEN = GL_GREEN, LAYOUT_BLUE = GL_BLUE, LAYOUT_BGR = GL_BGR, LAYOUT_BGRA = GL_BGRA
}
 Layout of channels.
 
enum  ChannelType {
  TYPE_UNKNOWN, TYPE_BYTE = GL_BYTE, TYPE_UBYTE = GL_UNSIGNED_BYTE, TYPE_SHORT = GL_SHORT,
  TYPE_USHORT = GL_UNSIGNED_SHORT, TYPE_FLOAT = GL_FLOAT, TYPE_INT = GL_INT, TYPE_UINT = GL_UNSIGNED_INT,
  TYPE_DOUBLE = GL_DOUBLE
}
 Data type of a single channel.
 
enum  Compression {
  COMPRESSION_NONE, COMPRESSED_RGB_DXT1 = GL_COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_DXT1 = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_DXT3 = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  COMPRESSED_RGBA_DXT5 = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
}
 Compression used. More...
 

Public Member Functions

int bytesPerPixel () const
 Returns the number of bytes in a single pixel.
 
Compression compression () const
 Returns the compression method.
 
bool hasAlpha () const
 Check if the format specifies an alpha channel. More...
 
ChannelLayout layout () const
 Returns the layout of the channels.
 
int numChannels () const
 Returns the number of channels.
 
bool operator!= (const PixelFormat &that) const
 Compare if two pixel formats are not the same.
 
bool operator== (const PixelFormat &that) const
 Compare if two pixel formats are the same.
 
 PixelFormat (const PixelFormat &pf)
 Constructs a copy. More...
 
 PixelFormat (ChannelLayout layout=LAYOUT_UNKNOWN, ChannelType type=TYPE_UNKNOWN)
 Constructs a pixel format with the given info. More...
 
 PixelFormat (Compression compression)
 Constructs a pixel format using compression. More...
 
QString toString () const
 Converts the pixel format into a human-readable string.
 
ChannelType type () const
 Returns the data type of the channels.
 

Static Public Member Functions

static PixelFormat alphaUByte ()
 Constructs an 8-bit alpha-only pixel format. More...
 
static PixelFormat bgraUByte ()
 Constructs an 8-bit BGRA pixel format. More...
 
static PixelFormat bgrUByte ()
 Constructs an 8-bit BGR pixel format. More...
 
static PixelFormat blueUByte ()
 Constructs an 8-bit blue pixel format. More...
 
static PixelFormat greenUByte ()
 Constructs an 8-bit green pixel format. More...
 
static PixelFormat redFloat ()
 Constructs a floating-point luminance pixel format.
 
static PixelFormat redGreenFloat ()
 Constructs a floating-point luminance-alpha pixel format.
 
static PixelFormat redGreenUByte ()
 Constructs an 8-bit luminance-alpha pixel format. More...
 
static PixelFormat redUByte ()
 Constructs an 8-bit red pixel format. More...
 
static PixelFormat rgbaUByte ()
 Constructs an 8-bit RGBA pixel format. More...
 
static PixelFormat rgbUByte ()
 Constructs an 8-bit RGB pixel format. More...
 

Detailed Description

Describes the pixel format of an image.

This class tells what type values there are in the pixels, and how they are aligned. It is implemented in a way that makes it easy to convert the pixel formats

Member Enumeration Documentation

Compression used.

Enumerator
COMPRESSION_NONE 

No compression.

COMPRESSED_RGB_DXT1 

DXT1 RGB compression.

COMPRESSED_RGBA_DXT1 

DXT1 RGBA compression.

COMPRESSED_RGBA_DXT3 

DXT3 RGBA compression.

COMPRESSED_RGBA_DXT5 

DXT5 RGBA compression.

Constructor & Destructor Documentation

Luminous::PixelFormat::PixelFormat ( const PixelFormat pf)

Constructs a copy.

Parameters
pfpixel format to copy
Luminous::PixelFormat::PixelFormat ( ChannelLayout  layout = LAYOUT_UNKNOWN,
ChannelType  type = TYPE_UNKNOWN 
)

Constructs a pixel format with the given info.

Parameters
layoutlayout of the channels
typechannel data type
Luminous::PixelFormat::PixelFormat ( Compression  compression)

Constructs a pixel format using compression.

Parameters
compressioncompression to use

Member Function Documentation

static PixelFormat Luminous::PixelFormat::alphaUByte ( )
inlinestatic

Constructs an 8-bit alpha-only pixel format.

Returns
new pixel format
static PixelFormat Luminous::PixelFormat::bgraUByte ( )
inlinestatic

Constructs an 8-bit BGRA pixel format.

Returns
new pixel format
static PixelFormat Luminous::PixelFormat::bgrUByte ( )
inlinestatic

Constructs an 8-bit BGR pixel format.

Some platforms do not support this format.

static PixelFormat Luminous::PixelFormat::blueUByte ( )
inlinestatic

Constructs an 8-bit blue pixel format.

Returns
new pixel format
static PixelFormat Luminous::PixelFormat::greenUByte ( )
inlinestatic

Constructs an 8-bit green pixel format.

Returns
new pixel format
bool Luminous::PixelFormat::hasAlpha ( ) const

Check if the format specifies an alpha channel.

Returns
true if alpha channel is specified; otherwise false
static PixelFormat Luminous::PixelFormat::redGreenUByte ( )
inlinestatic

Constructs an 8-bit luminance-alpha pixel format.

Returns
new pixel format
static PixelFormat Luminous::PixelFormat::redUByte ( )
inlinestatic

Constructs an 8-bit red pixel format.

This format is commonly used for storing grayscale images.

Returns
new pixel format
static PixelFormat Luminous::PixelFormat::rgbaUByte ( )
inlinestatic

Constructs an 8-bit RGBA pixel format.

Returns
new pixel format
static PixelFormat Luminous::PixelFormat::rgbUByte ( )
inlinestatic

Constructs an 8-bit RGB pixel format.

Returns
new pixel format