pixel.hpp
Go to the documentation of this file.
/*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
#ifndef __CLAW_PIXEL_HPP_
#define __CLAW_PIXEL_HPP_
#include <string>
namespace claw
{
namespace graphic
{
struct rgba_pixel;
struct rgb_pixel
{
typedef unsigned char component_type;
struct
{
component_type red;
component_type green;
component_type blue;
} components;
public:
rgb_pixel();
rgb_pixel( component_type r, component_type g, component_type b );
rgb_pixel( const rgba_pixel& p );
explicit rgb_pixel( const std::string& c );
bool operator==(const rgb_pixel& that) const;
bool operator==(const rgba_pixel& that) const;
bool operator!=(const rgb_pixel& that) const;
bool operator!=(const rgba_pixel& that) const;
}; // struct rgb_pixel
struct rgba_pixel
{
typedef unsigned char component_type;
union
{
unsigned int pixel;
struct
{
component_type red;
component_type green;
component_type blue;
component_type alpha;
} components;
};
public:
rgba_pixel();
rgba_pixel( const rgb_pixel& that );
rgba_pixel( component_type r, component_type g, component_type b,
component_type a );
explicit rgba_pixel( const std::string& c );
rgba_pixel& operator=( const rgb_pixel& that );
bool operator==( const rgba_pixel& that ) const;
bool operator!=( const rgba_pixel& that ) const;
component_type luminosity() const;
}; // struct rgba_pixel
typedef rgb_pixel rgb_pixel_8;
typedef rgba_pixel rgba_pixel_8;
extern rgba_pixel transparent_pixel;
extern rgba_pixel black_pixel;
extern rgba_pixel white_pixel;
extern rgba_pixel blue_pixel;
extern rgba_pixel green_pixel;
extern rgba_pixel red_pixel;
extern rgba_pixel yellow_pixel;
extern rgba_pixel magenta_pixel;
extern rgba_pixel cyan_pixel;
} // namespace graphic
} // namespace claw
#endif // __CLAW_PIXEL_HPP__
claw::graphic::cyan_pixel
rgba_pixel cyan_pixel(0, std::numeric_limits< rgba_pixel::component_type >::max(), std::numeric_limits< rgba_pixel::component_type >::max(), std::numeric_limits< rgba_pixel::component_type >::max())
The cyan color.
Definition pixel.hpp:157
claw::graphic::blue_pixel
rgba_pixel blue_pixel(0, 0, std::numeric_limits< rgba_pixel::component_type >::max(), std::numeric_limits< rgba_pixel::component_type >::max())
The blue color.
Definition pixel.hpp:142
claw::graphic::black_pixel
rgba_pixel black_pixel(0, 0, 0, std::numeric_limits< rgba_pixel::component_type >::max())
The black color.
Definition pixel.hpp:136
claw::graphic::red_pixel
rgba_pixel red_pixel
The red color.
claw::graphic::green_pixel
rgba_pixel green_pixel(0, std::numeric_limits< rgba_pixel::component_type >::max(), 0, std::numeric_limits< rgba_pixel::component_type >::max())
The green color.
Definition pixel.hpp:145
claw::graphic::white_pixel
rgba_pixel white_pixel
The white color.
claw::graphic::transparent_pixel
rgba_pixel transparent_pixel(0, 0, 0, 0)
A transparent color.
Definition pixel.hpp:133
claw::graphic::yellow_pixel
rgba_pixel yellow_pixel
The yellow color.
claw::graphic::magenta_pixel
rgba_pixel magenta_pixel
The magenta color.
claw::graphic
Everything about image structures and processing.
Definition bitmap.hpp:43
claw::graphic::rgba_pixel_8
rgba_pixel rgba_pixel_8
A color with 8 bits per component and an alpha channel.
Definition pixel.hpp:126
claw::graphic::rgb_pixel_8
rgb_pixel rgb_pixel_8
A color with 8 bits per component.
Definition pixel.hpp:123
claw
This is the main namespace.
Definition algorithm.hpp:34
claw::graphic::rgb_pixel
RGB pixel.
Definition pixel.hpp:45
claw::graphic::rgb_pixel::red
component_type red
Red component.
Definition pixel.hpp:53
claw::graphic::rgb_pixel::blue
component_type blue
Blue component.
Definition pixel.hpp:59
claw::graphic::rgb_pixel::operator==
bool operator==(const rgb_pixel &that) const
Compare to a pixel.
Definition pixel.cpp:146
claw::graphic::rgb_pixel::components
struct claw::graphic::rgb_pixel::@360176101256342355150201256143010314323350117315 components
Component by component representation.
claw::graphic::rgb_pixel::component_type
unsigned char component_type
The type of the components of the color.
Definition pixel.hpp:47
claw::graphic::rgb_pixel::green
component_type green
Green component.
Definition pixel.hpp:56
claw::graphic::rgb_pixel::operator!=
bool operator!=(const rgb_pixel &that) const
Compare to a pixel.
Definition pixel.cpp:168
claw::graphic::rgb_pixel::rgb_pixel
rgb_pixel()
Default constructor.
Definition pixel.cpp:88
claw::graphic::rgba_pixel
RGBA pixel.
Definition pixel.hpp:80
claw::graphic::rgba_pixel::component_type
unsigned char component_type
The type of the components of the color.
Definition pixel.hpp:82
claw::graphic::rgba_pixel::operator=
rgba_pixel & operator=(const rgb_pixel &that)
Assignement operator.
Definition pixel.cpp:265
claw::graphic::rgba_pixel::red
component_type red
Red component.
Definition pixel.hpp:93
claw::graphic::rgba_pixel::luminosity
component_type luminosity() const
Get the luminosity of the pixel.
Definition pixel.cpp:306
claw::graphic::rgba_pixel::components
struct claw::graphic::rgba_pixel::@121015363347207306133246064116275055130111004154::@053203370171110254125315021327231332025274313004 components
Component by component representation.
claw::graphic::rgba_pixel::operator!=
bool operator!=(const rgba_pixel &that) const
Tell if two pixels are different.
Definition pixel.cpp:290
claw::graphic::rgba_pixel::operator==
bool operator==(const rgba_pixel &that) const
Tell if two pixels are equal.
Definition pixel.cpp:280
claw::graphic::rgba_pixel::alpha
component_type alpha
Translucy.
Definition pixel.hpp:102
claw::graphic::rgba_pixel::green
component_type green
Green component.
Definition pixel.hpp:96
claw::graphic::rgba_pixel::blue
component_type blue
Blue component.
Definition pixel.hpp:99
claw::graphic::rgba_pixel::pixel
unsigned int pixel
Compressed representation.
Definition pixel.hpp:87
claw::graphic::rgba_pixel::rgba_pixel
rgba_pixel()
Default constructor.
Definition pixel.cpp:190