pixel.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00030 #include <claw/pixel.hpp>
00031
00032 #include <limits>
00033
00034 namespace claw
00035 {
00036 namespace graphic
00037 {
00038 rgba_pixel black_pixel
00039 ( 0, 0, 0, std::numeric_limits<rgba_pixel::component_type>::max() );
00040 rgba_pixel white_pixel
00041 ( std::numeric_limits<rgba_pixel::component_type>::max(),
00042 std::numeric_limits<rgba_pixel::component_type>::max(),
00043 std::numeric_limits<rgba_pixel::component_type>::max(),
00044 std::numeric_limits<rgba_pixel::component_type>::max() );
00045
00046 rgba_pixel blue_pixel
00047 ( 0, 0, std::numeric_limits<rgba_pixel::component_type>::max(),
00048 std::numeric_limits<rgba_pixel::component_type>::max() );
00049 rgba_pixel green_pixel
00050 ( 0, std::numeric_limits<rgba_pixel::component_type>::max(), 0,
00051 std::numeric_limits<rgba_pixel::component_type>::max() );
00052 rgba_pixel red_pixel
00053 ( std::numeric_limits<rgba_pixel::component_type>::max(), 0, 0,
00054 std::numeric_limits<rgba_pixel::component_type>::max() );
00055
00056 rgba_pixel yellow_pixel
00057 ( 0, std::numeric_limits<rgba_pixel::component_type>::max(),
00058 std::numeric_limits<rgba_pixel::component_type>::max(),
00059 std::numeric_limits<rgba_pixel::component_type>::max() );
00060 rgba_pixel magenta_pixel
00061 ( std::numeric_limits<rgba_pixel::component_type>::max(), 0,
00062 std::numeric_limits<rgba_pixel::component_type>::max(),
00063 std::numeric_limits<rgba_pixel::component_type>::max() );
00064 rgba_pixel cyan_pixel
00065 ( std::numeric_limits<rgba_pixel::component_type>::max(),
00066 std::numeric_limits<rgba_pixel::component_type>::max(), 0,
00067 std::numeric_limits<rgba_pixel::component_type>::max() );
00068
00069 }
00070 }
00071
00072
00076 claw::graphic::rgb_pixel::rgb_pixel()
00077 {
00078
00079 }
00080
00081
00088 claw::graphic::rgb_pixel::rgb_pixel
00089 ( component_type r, component_type g, component_type b )
00090 {
00091 components.red = r;
00092 components.green = g;
00093 components.blue = b;
00094 }
00095
00096
00101 claw::graphic::rgb_pixel::rgb_pixel( const rgba_pixel& p )
00102 {
00103 components.red = p.components.red;
00104 components.green = p.components.green;
00105 components.blue = p.components.blue;
00106 }
00107
00108
00113 bool claw::graphic::rgb_pixel::operator==(const rgb_pixel& that) const
00114 {
00115 return (components.red == that.components.red)
00116 && (components.green == that.components.green)
00117 && (components.blue == that.components.blue);
00118 }
00119
00120
00125 bool claw::graphic::rgb_pixel::operator==(const rgba_pixel& that) const
00126 {
00127 return *this == rgb_pixel(that);
00128 }
00129
00130
00135 bool claw::graphic::rgb_pixel::operator!=(const rgb_pixel& that) const
00136 {
00137 return !(*this == that);
00138 }
00139
00140
00145 bool claw::graphic::rgb_pixel::operator!=(const rgba_pixel& that) const
00146 {
00147 return !(*this == that);
00148 }
00149
00150
00151
00152
00153
00157 claw::graphic::rgba_pixel::rgba_pixel()
00158 {
00159
00160 }
00161
00162
00170 claw::graphic::rgba_pixel::rgba_pixel
00171 ( component_type r, component_type g, component_type b, component_type a )
00172 {
00173 components.red = r;
00174 components.green = g;
00175 components.blue = b;
00176 components.alpha = a;
00177 }
00178
00179
00185 claw::graphic::rgba_pixel&
00186 claw::graphic::rgba_pixel::operator=( const rgb_pixel& that )
00187 {
00188 components.red = that.components.red;
00189 components.green = that.components.green;
00190 components.blue = that.components.blue;
00191 components.alpha = 255;
00192
00193 return *this;
00194 }
00195
00196
00201 bool claw::graphic::rgba_pixel::operator==( const rgba_pixel& that ) const
00202 {
00203 return pixel == that.pixel;
00204 }
00205
00206
00211 bool claw::graphic::rgba_pixel::operator!=( const rgba_pixel& that ) const
00212 {
00213 return pixel != that.pixel;
00214 }
00215
00216
00226 claw::graphic::rgba_pixel::component_type
00227 claw::graphic::rgba_pixel::luminosity() const
00228 {
00229 return ((unsigned int)components.red * 183
00230 + (unsigned int)components.green * 54
00231 + (unsigned int)components.blue * 18
00232 ) / 256;
00233 }