|
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 PixelFormat * | format |
| 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 |
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.