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 #ifndef GNASH_FUZZYPIXEL_H
00021 #define GNASH_FUZZYPIXEL_H
00022
00023 #include "Range2d.h"
00024 #include "GnashKey.h"
00025 #include "RGBA.h"
00026
00027 #include <iostream>
00028
00029 namespace gnash {
00030
00032
00045 class FuzzyPixel
00046 {
00047
00048 public:
00049
00050 friend std::ostream& operator<< (std::ostream& o, const FuzzyPixel& p);
00051
00053
00057 FuzzyPixel()
00058 :
00059 _col(0,0,0,0),
00060 _tol(-1)
00061 {
00062 }
00063
00065
00072 FuzzyPixel(const rgba& color, short unsigned tolerance=0)
00073 :
00074 _col(color),
00075
00076
00077 _tol(int(tolerance))
00078 {
00079 }
00080
00082
00097 FuzzyPixel(boost::uint8_t r, boost::uint8_t g, boost::uint8_t b, boost::uint8_t a)
00098 :
00099 _col(r, g, b, a),
00100 _tol(0)
00101 {
00102 }
00103
00105
00109 void setTolerance(unsigned short tol)
00110 {
00111 _tol = int(tol);
00112 }
00113
00115 void setIntolerant()
00116 {
00117 _tol = -1;
00118 }
00119
00121
00127 bool operator==(const FuzzyPixel& other) const;
00128
00130 static bool fuzzyEqual(int a, int b, int tol)
00131 {
00132 return abs(a-b) <= tol;
00133 }
00134
00135 private:
00136
00137
00138 rgba _col;
00139
00140
00141 int _tol;
00142
00143 };
00144
00145 }
00146
00147 #endif // _GNASH_FUZZYPIXEL_H