00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef HxRgbStretch_h
00011 #define HxRgbStretch_h
00012
00013 #include "HxTagList.h"
00014 #include "HxClassName.h"
00015 #include "HxColConvert.h"
00016
00017
00021 template<class ValT, class ValDoubleT>
00022 class HxRgbStretch
00023 {
00024 public:
00026 typedef ValDoubleT ArithTypeDouble;
00027
00029 HxRgbStretch(HxTagList& tags)
00030 {
00031 _lowVal = HxGetTag(tags, "lowVal", double(0));
00032 _highVal = HxGetTag(tags, "highVal", double(255));
00033 _interval = _highVal - _lowVal;
00034 }
00035
00037 int doIt(const ValT& pixV)
00038 {
00039 HxVec3Double v = (HxVec3Double) pixV;
00040 int x = (int) (((v.x() - _lowVal) / _interval) * 255);
00041 int y = (int) (((v.y() - _lowVal) / _interval) * 255);
00042 int z = (int) (((v.z() - _lowVal) / _interval) * 255);
00043 return (255 << 24) | (x << 16) | (y << 8) | z;
00044 }
00045
00047 int doItDouble(const ValDoubleT& pixV)
00048 {
00049 HxVec3Double v = (HxVec3Double) pixV;
00050 int x = (int) (((v.x() - _lowVal) / _interval) * 255);
00051 int y = (int) (((v.y() - _lowVal) / _interval) * 255);
00052 int z = (int) (((v.z() - _lowVal) / _interval) * 255);
00053 return (255 << 24) | (x << 16) | (y << 8) | z;
00054 }
00055
00057 static HxString className()
00058 { return HxString("Stretch"); }
00059
00060 private:
00061 double _lowVal;
00062 double _highVal;
00063 double _interval;
00064 };
00065
00066
00067 #endif