00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SH_BMPRGBSAMPLEVALUE_H
00022 #define SH_BMPRGBSAMPLEVALUE_H
00023
00024 #include "BmpSampleValue.h"
00025 #include "RGBTriple.h"
00026 #include "common.h"
00027
00032 class BmpRGBSampleValue : public BmpSampleValue {
00033 public:
00034 BmpRGBSampleValue (BYTE r, BYTE g, BYTE b) ;
00035 BmpRGBSampleValue (RGBTriple t) ;
00036
00037 UWORD32 calcDistance (const SampleValue *s) const ;
00038 SampleValue* getNearestTargetSampleValue (EmbValue t) const ;
00039 std::string getName (void) const ;
00040
00041 BYTE getRed (void) const { return Color.Red ; } ;
00042 BYTE getGreen (void) const { return Color.Green ; } ;
00043 BYTE getBlue (void) const { return Color.Blue ; } ;
00044
00045 private:
00046 RGBTriple Color ;
00047
00048 UWORD32 calcKey (const RGBTriple& rgb) const
00049 { return (((UWORD32) rgb.Red << 16) | ((UWORD32) rgb.Green << 8) | ((UWORD32) rgb.Blue)) ;} ;
00050
00051 EmbValue calcEValue (const RGBTriple& rgb) const
00052
00053 { return ((EmbValue) ((((rgb.Red & 1) ^ (rgb.Green & 1)) << 1) | ((rgb.Red & 1) ^ (rgb.Blue & 1)))) ; } ;
00054
00055 enum COLOR { RED, GREEN, BLUE } ;
00056 enum DIRECTION { UP, DOWN } ;
00057
00062 BYTE plus (BYTE a, BYTE b) const ;
00063
00068 BYTE minus (BYTE a, BYTE b) const ;
00069
00077 void addNTSVCandidates (std::vector<RGBTriple>& cands, const BYTE cube[3][2], COLOR fc, DIRECTION fd, COLOR i1, COLOR i2, EmbValue t) const ;
00078 } ;
00079
00080 #endif // ndef SH_BMPRGBSAMPLEVALUE_H