CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
Public Types | Public Member Functions | Public Attributes

claw::graphic::rgba_pixel Struct 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 (const rgb_pixel &that)
 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

union {
   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
}; 

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 159 of file pixel.cpp.

{

} // rgba_pixel::rgba_pixel()
claw::graphic::rgba_pixel::rgba_pixel ( const rgb_pixel that)

Constructor.

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

Definition at line 170 of file pixel.cpp.

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

{
  components.red = that.components.red;
  components.green = that.components.green;
  components.blue = that.components.blue;
  components.alpha = 255;
} // rgba_pixel::rgba_pixel()
claw::graphic::rgba_pixel::rgba_pixel ( component_type  r,
component_type  g,
component_type  b,
component_type  a 
)

Constructor.

Parameters:
rThe value of the red field.
gThe value of the green field.
bThe value of the blue field.
aThe value of the alpha field.

Definition at line 187 of file pixel.cpp.

{ 
  components.red = r;
  components.green = g;
  components.blue = b;
  components.alpha = a;
} // 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 243 of file pixel.cpp.

{
  return ((unsigned int)components.red * 183 
          + (unsigned int)components.green * 54 
          + (unsigned int)components.blue * 18
          ) / 256;
} // rgba_pixel::luminosity()
bool claw::graphic::rgba_pixel::operator!= ( const rgba_pixel that) const

Tell if two pixels are different.

Parameters:
thatThe other pixel.

Definition at line 227 of file pixel.cpp.

References pixel.

{
  return pixel != that.pixel;
} // rgba_pixel::operator!=()
claw::graphic::rgba_pixel & claw::graphic::rgba_pixel::operator= ( const rgb_pixel that)

Assignement operator.

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

Definition at line 202 of file pixel.cpp.

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

{
  components.red = that.components.red;
  components.green = that.components.green;
  components.blue = that.components.blue;
  components.alpha = 255;

  return *this;
} // rgba_pixel::operator=()
bool claw::graphic::rgba_pixel::operator== ( const rgba_pixel that) const

Tell if two pixels are equal.

Parameters:
thatThe other pixel.

Definition at line 217 of file pixel.cpp.

References pixel.

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

Member Data Documentation

union { ... }

Translucy.

Definition at line 97 of file pixel.hpp.

Blue component.

Definition at line 94 of file pixel.hpp.

Green component.

Definition at line 91 of file pixel.hpp.

Compressed representation.

Definition at line 82 of file pixel.hpp.

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

Red component.

Definition at line 88 of file pixel.hpp.

Referenced by operator=().


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