CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5

pixel.hpp

Go to the documentation of this file.
00001 /*
00002   CLAW - a C++ Library Absolutely Wonderful
00003 
00004   CLAW is a free library without any particular aim but being useful to 
00005   anyone.
00006 
00007   Copyright (C) 2005-2010 Julien Jorge
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023   contact: julien_jorge@yahoo.fr
00024 */
00030 #ifndef __CLAW_PIXEL_HPP_
00031 #define __CLAW_PIXEL_HPP_
00032 
00033 namespace claw
00034 {
00035   namespace graphic
00036   {
00037     struct rgba_pixel;
00038 
00042     struct rgb_pixel
00043     {
00044       typedef unsigned char component_type;
00045 
00047       struct
00048       {
00050         component_type red;
00051 
00053         component_type green;
00054 
00056         component_type blue;
00057 
00058       } components; 
00059 
00060     public:
00061       rgb_pixel();
00062       rgb_pixel( component_type r, component_type g, component_type b );
00063       rgb_pixel( const rgba_pixel& p );
00064 
00065       bool operator==(const rgb_pixel& that) const;
00066       bool operator==(const rgba_pixel& that) const;
00067       bool operator!=(const rgb_pixel& that) const;
00068       bool operator!=(const rgba_pixel& that) const;
00069 
00070     }; // struct rgb_pixel
00071 
00075     struct rgba_pixel
00076     {
00077       typedef unsigned char component_type;
00078 
00079       union
00080       {
00082   unsigned int pixel;
00083 
00085   struct
00086   {
00088     component_type red;
00089 
00091     component_type green;
00092 
00094     component_type blue;
00095 
00097     component_type alpha;
00098 
00099   } components;
00100       };
00101 
00102     public:
00103       rgba_pixel();
00104       rgba_pixel( const rgb_pixel& that );
00105       rgba_pixel( component_type r, component_type g, component_type b,
00106                   component_type a );
00107 
00108       rgba_pixel& operator=( const rgb_pixel& that );
00109       bool operator==( const rgba_pixel& that ) const;
00110       bool operator!=( const rgba_pixel& that ) const;
00111 
00112       component_type luminosity() const;
00113 
00114     }; // struct rgba_pixel
00115 
00116     typedef rgb_pixel rgb_pixel_8;
00117     typedef rgba_pixel rgba_pixel_8;
00118 
00119     extern rgba_pixel transparent_pixel;
00120 
00121     extern rgba_pixel black_pixel;
00122     extern rgba_pixel white_pixel;
00123 
00124     extern rgba_pixel blue_pixel;
00125     extern rgba_pixel green_pixel;
00126     extern rgba_pixel red_pixel;
00127 
00128     extern rgba_pixel yellow_pixel;
00129     extern rgba_pixel magenta_pixel;
00130     extern rgba_pixel cyan_pixel;
00131 
00132   } // namespace graphic
00133 } // namespace claw
00134 
00135 #endif // __CLAW_PIXEL_HPP__