Claw  1.7.3
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-2011 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@gamned.org
00024 */
00030 #ifndef __CLAW_PIXEL_HPP_
00031 #define __CLAW_PIXEL_HPP_
00032 
00033 #include <string>
00034 
00035 namespace claw
00036 {
00037   namespace graphic
00038   {
00039     struct rgba_pixel;
00040 
00044     struct rgb_pixel
00045     {
00047       typedef unsigned char component_type;
00048 
00050       struct
00051       {
00053         component_type red;
00054 
00056         component_type green;
00057 
00059         component_type blue;
00060 
00061       } components; 
00062 
00063     public:
00064       rgb_pixel();
00065       rgb_pixel( component_type r, component_type g, component_type b );
00066       rgb_pixel( const rgba_pixel& p );
00067       explicit rgb_pixel( const std::string& c );
00068 
00069       bool operator==(const rgb_pixel& that) const;
00070       bool operator==(const rgba_pixel& that) const;
00071       bool operator!=(const rgb_pixel& that) const;
00072       bool operator!=(const rgba_pixel& that) const;
00073 
00074     }; // struct rgb_pixel
00075 
00079     struct rgba_pixel
00080     {
00082       typedef unsigned char component_type;
00083 
00084       union
00085       {
00087   unsigned int pixel;
00088 
00090   struct
00091   {
00093     component_type red;
00094 
00096     component_type green;
00097 
00099     component_type blue;
00100 
00102     component_type alpha;
00103 
00104   } components;
00105       };
00106 
00107     public:
00108       rgba_pixel();
00109       rgba_pixel( const rgb_pixel& that );
00110       rgba_pixel( component_type r, component_type g, component_type b,
00111                   component_type a );
00112       explicit rgba_pixel( const std::string& c );
00113 
00114       rgba_pixel& operator=( const rgb_pixel& that );
00115       bool operator==( const rgba_pixel& that ) const;
00116       bool operator!=( const rgba_pixel& that ) const;
00117 
00118       component_type luminosity() const;
00119 
00120     }; // struct rgba_pixel
00121 
00123     typedef rgb_pixel rgb_pixel_8;
00124 
00126     typedef rgba_pixel rgba_pixel_8;
00127 
00133     extern rgba_pixel transparent_pixel;
00134 
00136     extern rgba_pixel black_pixel;
00137 
00139     extern rgba_pixel white_pixel;
00140 
00142     extern rgba_pixel blue_pixel;
00143 
00145     extern rgba_pixel green_pixel;
00146 
00148     extern rgba_pixel red_pixel;
00149 
00151     extern rgba_pixel yellow_pixel;
00152 
00154     extern rgba_pixel magenta_pixel;
00155 
00157     extern rgba_pixel cyan_pixel;
00158 
00161   } // namespace graphic
00162 } // namespace claw
00163 
00164 #endif // __CLAW_PIXEL_HPP__