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

fl::PixelFormat Class Reference

#include <image.h>

Inheritance diagram for fl::PixelFormat:

fl::Filter fl::PixelFormatGrayChar fl::PixelFormatGrayDouble fl::PixelFormatGrayFloat fl::PixelFormatHLSFloat fl::PixelFormatRGBABits fl::PixelFormatRGBAChar fl::PixelFormatRGBAFloat fl::PixelFormatVYUYChar fl::PixelFormatYVYUChar List of all members.

Public Methods

virtual Image filter (const Image &image)
 Return an Image in this format.

void fromAny (const Image &image, Image &result) const
virtual bool operator== (const PixelFormat &that) const
 Checks if this and that describe the same actual format.

bool operator!= (const PixelFormat &that) const
virtual unsigned int getRGBA (void *pixel) const=0
 Return value is always assumed to be non-linear sRGB. Same for other RGB methods below.

virtual void getRGBA (void *pixel, float values[]) const
 "values" must have at least four elements. Each returned value is in [0,1].

virtual void getXYZ (void *pixel, float values[]) const
virtual unsigned int getYUV (void *pixel) const
virtual unsigned char getGray (void *pixel) const
virtual void getGray (void *pixel, float &gray) const
virtual unsigned char getAlpha (void *pixel) const
 Returns fully opaque by default. PixelFormats that actually have an alpha channel must override this to return correct value.

virtual void setRGBA (void *pixel, unsigned int rgba) const=0
virtual void setRGBA (void *pixel, float values[]) const
 Each value must be in [0,1]. Values outside this range will be clamped and modified directly in the array.

virtual void setXYZ (void *pixel, float values[]) const
virtual void setYUV (void *pixel, unsigned int yuv) const
virtual void setGray (void *pixel, unsigned char gray) const
virtual void setGray (void *pixel, float gray) const
virtual void setAlpha (void *pixel, unsigned char alpha) const
 Ignored by default. Formats that actually have an alpha channel must override this method.


Public Attributes

int depth
 Number of bytes in one pixel, including any padding.

int precedence
 Imposes a (partial?) order on formats according to information content. Bigger numbers have more information.

bool monochrome
 Indicates that this format has no color components.

bool hasAlpha
 Indicates that this format has a real alpha channel (as apposed to a default alpha value).


Detailed Description

A PixelFormat wraps access to an element of an Image. A pixel itself is sort of the combination of a pointer to memory and a PixelFormat. A PixelFormat describes the entire collection of pixels in an image, and we use it to interpret each pixel in the image. PixelFormat extends Filter so it can be used directly to convert image format. The "from*" methods implement an n^2 set of direct conversions between selected formats. These conversions occur frequently when displaying images on an X windows system. For the present, all formats exept for XYZ make sRGB assumptions (see www.srgb.com). In addition, all integer values are non-linear (with gamma = 2.2 as per sRGB spec), and all floating point values are linear. We can add parameters to the formats if we need to distinguish more color spaces. Naming convention: <color space><basic C type for one channel> Color space names refer to sequence of channels (usually bytes) in memory, rather than in machine words (eg: registers in the processor). The leftmost letter in a name refers to the lowest numbered address. The "Bits" formats also follow this convention with two exceptions: 1) The bitmasks are necessarily machine words. 2) The order of channels is actually arbitrary. TODO: Finish thinking about the naming convention and then actually apply it. Fix code to work on both endians (right now it is just little endian). think about adding arbitrary information channels besides alpha (eg: depth). alpha gets special treatment because it has a specific, well-defined effect on how pixels are combined. add alpha blend methods (operator<< and >>) to Pixel


Member Function Documentation

Image PixelFormat::filter const Image   image [virtual]
 

Return an Image in this format.

Implements fl::Filter.

Reimplemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, fl::PixelFormatGrayDouble, fl::PixelFormatRGBAChar, fl::PixelFormatRGBABits, fl::PixelFormatYVYUChar, and fl::PixelFormatVYUYChar.

void PixelFormat::fromAny const Image   image,
Image   result
const
 

Reimplemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, and fl::PixelFormatGrayDouble.

unsigned char PixelFormat::getAlpha void *    pixel const [virtual]
 

Returns fully opaque by default. PixelFormats that actually have an alpha channel must override this to return correct value.

Reimplemented in fl::PixelFormatRGBAChar, fl::PixelFormatRGBABits, and fl::PixelFormatRGBAFloat.

void PixelFormat::getGray void *    pixel,
float &    gray
const [virtual]
 

Reimplemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, and fl::PixelFormatGrayDouble.

unsigned char PixelFormat::getGray void *    pixel const [virtual]
 

Reimplemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, fl::PixelFormatGrayDouble, fl::PixelFormatYVYUChar, and fl::PixelFormatVYUYChar.

void PixelFormat::getRGBA void *    pixel,
float    values[]
const [virtual]
 

"values" must have at least four elements. Each returned value is in [0,1].

Reimplemented in fl::PixelFormatGrayFloat, fl::PixelFormatGrayDouble, fl::PixelFormatRGBAFloat, and fl::PixelFormatHLSFloat.

virtual unsigned int fl::PixelFormat::getRGBA void *    pixel const [pure virtual]
 

Return value is always assumed to be non-linear sRGB. Same for other RGB methods below.

Implemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, fl::PixelFormatGrayDouble, fl::PixelFormatRGBAChar, fl::PixelFormatRGBABits, fl::PixelFormatRGBAFloat, fl::PixelFormatYVYUChar, fl::PixelFormatVYUYChar, and fl::PixelFormatHLSFloat.

void PixelFormat::getXYZ void *    pixel,
float    values[]
const [virtual]
 

Reimplemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, and fl::PixelFormatGrayDouble.

unsigned int PixelFormat::getYUV void *    pixel const [virtual]
 

See PixelFormatYVYUChar::setRGBA() for more details on the conversion matrix.

Reimplemented in fl::PixelFormatYVYUChar, and fl::PixelFormatVYUYChar.

bool fl::PixelFormat::operator!= const PixelFormat &    that const [inline]
 

bool PixelFormat::operator== const PixelFormat &    that const [virtual]
 

Checks if this and that describe the same actual format.

Reimplemented in fl::PixelFormatRGBAChar, and fl::PixelFormatRGBABits.

void PixelFormat::setAlpha void *    pixel,
unsigned char    alpha
const [virtual]
 

Ignored by default. Formats that actually have an alpha channel must override this method.

Reimplemented in fl::PixelFormatRGBAChar, fl::PixelFormatRGBABits, and fl::PixelFormatRGBAFloat.

void PixelFormat::setGray void *    pixel,
float    gray
const [virtual]
 

Reimplemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, and fl::PixelFormatGrayDouble.

void PixelFormat::setGray void *    pixel,
unsigned char    gray
const [virtual]
 

Reimplemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, and fl::PixelFormatGrayDouble.

void PixelFormat::setRGBA void *    pixel,
float    values[]
const [virtual]
 

Each value must be in [0,1]. Values outside this range will be clamped and modified directly in the array.

Reimplemented in fl::PixelFormatGrayFloat, fl::PixelFormatGrayDouble, fl::PixelFormatRGBAFloat, and fl::PixelFormatHLSFloat.

virtual void fl::PixelFormat::setRGBA void *    pixel,
unsigned int    rgba
const [pure virtual]
 

Implemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, fl::PixelFormatGrayDouble, fl::PixelFormatRGBAChar, fl::PixelFormatRGBABits, fl::PixelFormatRGBAFloat, fl::PixelFormatYVYUChar, fl::PixelFormatVYUYChar, and fl::PixelFormatHLSFloat.

void PixelFormat::setXYZ void *    pixel,
float    values[]
const [virtual]
 

Reimplemented in fl::PixelFormatGrayChar, fl::PixelFormatGrayFloat, and fl::PixelFormatGrayDouble.

void PixelFormat::setYUV void *    pixel,
unsigned int    yuv
const [virtual]
 

Reimplemented in fl::PixelFormatYVYUChar, and fl::PixelFormatVYUYChar.


Member Data Documentation

int fl::PixelFormat::depth
 

Number of bytes in one pixel, including any padding.

bool fl::PixelFormat::hasAlpha
 

Indicates that this format has a real alpha channel (as apposed to a default alpha value).

bool fl::PixelFormat::monochrome
 

Indicates that this format has no color components.

int fl::PixelFormat::precedence
 

Imposes a (partial?) order on formats according to information content. Bigger numbers have more information.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 17:13:26 2004 for fl by doxygen1.2.18