Claw 1.7.0
|
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 { 00046 typedef unsigned char component_type; 00047 00049 struct 00050 { 00052 component_type red; 00053 00055 component_type green; 00056 00058 component_type blue; 00059 00060 } components; 00061 00062 public: 00063 rgb_pixel(); 00064 rgb_pixel( component_type r, component_type g, component_type b ); 00065 rgb_pixel( const rgba_pixel& p ); 00066 explicit rgb_pixel( const std::string& c ); 00067 00068 bool operator==(const rgb_pixel& that) const; 00069 bool operator==(const rgba_pixel& that) const; 00070 bool operator!=(const rgb_pixel& that) const; 00071 bool operator!=(const rgba_pixel& that) const; 00072 00073 }; // struct rgb_pixel 00074 00078 struct rgba_pixel 00079 { 00080 typedef unsigned char component_type; 00081 00082 union 00083 { 00085 unsigned int pixel; 00086 00088 struct 00089 { 00091 component_type red; 00092 00094 component_type green; 00095 00097 component_type blue; 00098 00100 component_type alpha; 00101 00102 } components; 00103 }; 00104 00105 public: 00106 rgba_pixel(); 00107 rgba_pixel( const rgb_pixel& that ); 00108 rgba_pixel( component_type r, component_type g, component_type b, 00109 component_type a ); 00110 explicit rgba_pixel( const std::string& c ); 00111 00112 rgba_pixel& operator=( const rgb_pixel& that ); 00113 bool operator==( const rgba_pixel& that ) const; 00114 bool operator!=( const rgba_pixel& that ) const; 00115 00116 component_type luminosity() const; 00117 00118 }; // struct rgba_pixel 00119 00120 typedef rgb_pixel rgb_pixel_8; 00121 typedef rgba_pixel rgba_pixel_8; 00122 00123 extern rgba_pixel transparent_pixel; 00124 00125 extern rgba_pixel black_pixel; 00126 extern rgba_pixel white_pixel; 00127 00128 extern rgba_pixel blue_pixel; 00129 extern rgba_pixel green_pixel; 00130 extern rgba_pixel red_pixel; 00131 00132 extern rgba_pixel yellow_pixel; 00133 extern rgba_pixel magenta_pixel; 00134 extern rgba_pixel cyan_pixel; 00135 00136 } // namespace graphic 00137 } // namespace claw 00138 00139 #endif // __CLAW_PIXEL_HPP__