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-2008 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 union 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 union rgba_pixel 00076 { 00077 typedef unsigned char component_type; 00078 00080 unsigned int pixel; 00081 00083 struct 00084 { 00086 component_type red; 00087 00089 component_type green; 00090 00092 component_type blue; 00093 00095 component_type alpha; 00096 00097 } components; 00098 00099 public: 00100 rgba_pixel(); 00101 rgba_pixel( component_type r, component_type g, component_type b, 00102 component_type a ); 00103 00104 rgba_pixel& operator=( const rgb_pixel& that ); 00105 bool operator==( const rgba_pixel& that ) const; 00106 bool operator!=( const rgba_pixel& that ) const; 00107 00108 component_type luminosity() const; 00109 00110 }; // struct rgba_pixel 00111 00112 typedef rgb_pixel rgb_pixel_8; 00113 typedef rgba_pixel rgba_pixel_8; 00114 00115 extern rgba_pixel black_pixel; 00116 extern rgba_pixel white_pixel; 00117 00118 extern rgba_pixel blue_pixel; 00119 extern rgba_pixel green_pixel; 00120 extern rgba_pixel red_pixel; 00121 00122 extern rgba_pixel yellow_pixel; 00123 extern rgba_pixel magenta_pixel; 00124 extern rgba_pixel cyan_pixel; 00125 00126 } // namespace graphic 00127 } // namespace claw 00128 00129 #endif // __CLAW_PIXEL_HPP__