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

fl::Pixel Class Reference

#include <image.h>

List of all members.

Public Methods

 Pixel ()
 Pixel (unsigned int rgba)
 Pixel (const Pixel &that)
 Pixel (const PixelFormat &format, void *pixel)
unsigned int getRGBA () const
void getRGBA (float values[]) const
void getXYZ (float values[]) const
void setRGBA (unsigned int rgba) const
void setRGBA (float values[]) const
void setXYZ (float values[]) const
Pixel & operator= (const Pixel &that)
 Set self to have color contained in that.

Pixel & operator+= (const Pixel &that)
 Set self to sum of respective color channels.

Pixel operator+ (const Pixel &that) const
 Add respective color channels.

Pixel operator * (const Pixel &that) const
 Multiply respective color channels.

Pixel operator * (float scalar) const
 Scale each channel.

Pixel operator/ (float scalar) const
 Scale each channel.

Pixel operator<< (const Pixel &that)
 Alpha blend that into this. The alpha value the governs the blending comes from that.


Public Attributes

const PixelFormatformat
void * pixel
 always points to target data: either the union below or some point in an Image buffer

union {
   unsigned char   graychar
   float   grayfloat
   double   graydouble
   unsigned int   rgbchar
   float   rgbafloat [4]
data


Detailed Description

Provides convenient access to the functions of PixelFormat for a specific datum. All linear operations between pixels take place in RGB space. It would be better colorwise to do them in XYZ space, but most formats are closer to RGB than XYZ numerically (ie: require less conversion), so it is cheaper to do them in RGB.

There are two possible ways to think of this class: 1) It provides a shorthand for applying the color access functions of PixelFormat to a particular (x,y) position in an image. E.g.: image(x,y).getRGBA () <=> image.format->getRGBA (image(x,y)) assuming the image(x,y) is defined to return a void * to the correct address. 1.1) It provides a way of treating the operation image(x,y) as a reference to the pixel without actually knowing its format. 2) It provides an abstract way to do numerical operations on pixels, such as scaling, adding, and alpha-blending. As such, it should really be an extension of Vector<float>. The current implementation kind of munges these two ideas together, creating something that is rather inefficient for either purpose. Job 1 should be moved into class Image in the form of more color accessor functions. This makes most sense from an efficiency standpoint. It is not clear to me yet what to do about job 1.1 and job 2. Currently, the only code that makes serious use of Pixel uses it for both these jobs. However, it does not do this efficiently. Pixel would do jobs 1.1 and 2 more efficiently if we relieve it of the burden of storing intermediate results. We should instead store the intermediate results in Vector<float> as RGB values.


Constructor & Destructor Documentation

Pixel::Pixel  
 

Pixel::Pixel unsigned int    rgba
 

Pixel::Pixel const Pixel &    that
 

Pixel::Pixel const PixelFormat   format,
void *    pixel
 


Member Function Documentation

void Pixel::getRGBA float    values[] const
 

unsigned int Pixel::getRGBA  
 

void Pixel::getXYZ float    values[] const
 

Pixel Pixel::operator * float    scalar const
 

Scale each channel.

Pixel Pixel::operator * const Pixel &    that const
 

Multiply respective color channels.

Pixel Pixel::operator+ const Pixel &    that const
 

Add respective color channels.

Pixel & Pixel::operator+= const Pixel &    that
 

Set self to sum of respective color channels.

Pixel Pixel::operator/ float    scalar const
 

Scale each channel.

Pixel Pixel::operator<< const Pixel &    that
 

Alpha blend that into this. The alpha value the governs the blending comes from that.

Pixel & Pixel::operator= const Pixel &    that
 

Set self to have color contained in that.

void Pixel::setRGBA float    values[] const
 

void Pixel::setRGBA unsigned int    rgba const
 

void Pixel::setXYZ float    values[] const
 


Member Data Documentation

union { ... } fl::Pixel::data
 

const PixelFormat* fl::Pixel::format
 

unsigned char fl::Pixel::graychar
 

double fl::Pixel::graydouble
 

float fl::Pixel::grayfloat
 

void* fl::Pixel::pixel
 

always points to target data: either the union below or some point in an Image buffer

float fl::Pixel::rgbafloat[4]
 

unsigned int fl::Pixel::rgbchar
 


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