claw::graphic::rgba_pixel Union Reference

RGBA pixel. More...

#include <pixel.hpp>

List of all members.

Public Types

typedef unsigned char component_type

Public Member Functions

 rgba_pixel ()
 Default constructor.
 rgba_pixel (component_type r, component_type g, component_type b, component_type a)
 Constructor.
rgba_pixeloperator= (const rgb_pixel &that)
 Assignement operator.
bool operator== (const rgba_pixel &that) const
 Tell if two pixels are equal.
bool operator!= (const rgba_pixel &that) const
 Tell if two pixels are different.
component_type luminosity () const
 Get the luminosity of the pixel.

Public Attributes

unsigned int pixel
 Compressed representation.
struct {
   component_type   red
 Red component.
   component_type   green
 Green component.
   component_type   blue
 Blue component.
   component_type   alpha
 Translucy.
components
 Component by component representation.

Detailed Description

RGBA pixel.

Definition at line 75 of file pixel.hpp.


Member Typedef Documentation

Definition at line 77 of file pixel.hpp.


Constructor & Destructor Documentation

claw::graphic::rgba_pixel::rgba_pixel (  ) 

Default constructor.

Definition at line 157 of file pixel.cpp.

00158 {
00159 
00160 } // rgba_pixel::rgba_pixel()

claw::graphic::rgba_pixel::rgba_pixel ( component_type  r,
component_type  g,
component_type  b,
component_type  a 
)

Constructor.

Parameters:
r The value of the red field.
g The value of the green field.
b The value of the blue field.
a The value of the alpha field.

Definition at line 171 of file pixel.cpp.

00172 { 
00173   components.red = r;
00174   components.green = g;
00175   components.blue = b;
00176   components.alpha = a;
00177 } // rgba_pixel::rgba_pixel()


Member Function Documentation

claw::graphic::rgba_pixel::component_type claw::graphic::rgba_pixel::luminosity (  )  const

Get the luminosity of the pixel.

Returns:
The luminosity between 0 (dark) and 255 (light).

The luminosity is approximated with integers: $0,715160 \simeq 183 \div 256 = 0,71484375 $ $0,212671 \simeq 54 \div 256 = 0,2109375 $ $0,072169 \simeq 18 \div 256 = 0,0703125 $

Definition at line 227 of file pixel.cpp.

References components.

00228 {
00229   return ((unsigned int)components.red * 183 
00230           + (unsigned int)components.green * 54 
00231           + (unsigned int)components.blue * 18
00232           ) / 256;
00233 } // rgba_pixel::luminosity()

bool claw::graphic::rgba_pixel::operator!= ( const rgba_pixel that  )  const

Tell if two pixels are different.

Parameters:
that The other pixel.

Definition at line 211 of file pixel.cpp.

References pixel.

00212 {
00213   return pixel != that.pixel;
00214 } // rgba_pixel::operator!=()

claw::graphic::rgba_pixel & claw::graphic::rgba_pixel::operator= ( const rgb_pixel that  ) 

Assignement operator.

Parameters:
that The other pixel.
Remarks:
The alpha component of the this is set to 255.

Definition at line 186 of file pixel.cpp.

References claw::graphic::rgb_pixel::blue, claw::graphic::rgb_pixel::components, components, claw::graphic::rgb_pixel::green, and claw::graphic::rgb_pixel::red.

00187 {
00188   components.red = that.components.red;
00189   components.green = that.components.green;
00190   components.blue = that.components.blue;
00191   components.alpha = 255;
00192 
00193   return *this;
00194 } // rgba_pixel::operator=()

bool claw::graphic::rgba_pixel::operator== ( const rgba_pixel that  )  const

Tell if two pixels are equal.

Parameters:
that The other pixel.

Definition at line 201 of file pixel.cpp.

References pixel.

00202 {
00203   return pixel == that.pixel;
00204 } // rgba_pixel::operator==()


Member Data Documentation

Compressed representation.

Definition at line 80 of file pixel.hpp.

Referenced by operator!=(), and operator==().


The documentation for this union was generated from the following files:

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1