2
CLAW - a C++ Library Absolutely Wonderful
4
CLAW is a free library without any particular aim but being useful to
7
Copyright (C) 2005-2008 Julien Jorge
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Lesser General Public
11
License as published by the Free Software Foundation; either
12
version 2.1 of the License, or (at your option) any later version.
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Lesser General Public License for more details.
19
You should have received a copy of the GNU Lesser General Public
20
License along with this library; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
contact: julien_jorge@yahoo.fr
27
* \brief Representation of a pixel in image processing.
28
* \author Julien Jorge
30
#ifndef __CLAW_PIXEL_HPP_
31
#define __CLAW_PIXEL_HPP_
42
typedef unsigned char component_type;
44
/** \brief Component by component representation. */
47
/** \brief Red component. */
50
/** \brief Green component. */
53
/** \brief Blue component. */
59
/** \brief Default constructor. */
64
* \param r The value of the red field.
65
* \param g The value of the green field.
66
* \param b The value of the blue field.
68
pixel24( component_type r, component_type g, component_type b )
82
typedef unsigned char component_type;
84
/** \brief Compressed representation. */
87
/** \brief Component by component representation. */
90
/** \brief Red component. */
93
/** \brief Green component. */
96
/** \brief Blue component. */
99
/** \brief Translucy. */
100
component_type alpha;
105
/** \brief Default constructor. */
109
* \brief Constructor.
110
* \param r The value of the red field.
111
* \param g The value of the green field.
112
* \param b The value of the blue field.
113
* \param a The value of the alpha field.
115
pixel32( component_type r, component_type g, component_type b,
119
components.green = g;
121
components.alpha = a;
125
* \brief Assignement operator.
126
* \param that The other pixel.
127
* \remark The alpha component of the \a this is set to 255.
129
pixel32& operator=( const pixel24& that )
131
components.red = that.components.red;
132
components.green = that.components.green;
133
components.blue = that.components.blue;
134
components.alpha = 255;
140
* \brief Tell if two pixels are equal.
141
* \param that The other pixel.
143
bool operator==( const pixel32& that ) const
145
return pixel == that.pixel;
149
* \brief Tell if two pixels are different.
150
* \param that The other pixel.
152
bool operator!=( const pixel32& that ) const
154
return pixel != that.pixel;
158
* \brief Get the luminosity of the pixel.
159
* \return The luminosity between 0 (dark) and 255 (light).
161
* The luminosity is approximated with integers:
162
* \f$0,715160 \simeq 183 \div 256 = 0,71484375 \f$
163
* \f$0,212671 \simeq 54 \div 256 = 0,2109375 \f$
164
* \f$0,072169 \simeq 18 \div 256 = 0,0703125 \f$
166
component_type luminosity() const
168
return ((unsigned int)components.red * 183
169
+ (unsigned int)components.green * 54
170
+ (unsigned int)components.blue * 18
175
} // namespace graphic
178
#endif // __CLAW_PIXEL_HPP__