00001
00002
00003
00004 #pragma hdrstop
00005
00006 #include "contrast.h"
00007
00008
00009
00010 unsigned char __fastcall TContrast::getVal(__int16 val)
00011 {
00012
00013 if (val <= _lowerAbs)
00014 return 0;
00015 else if (val >= _upperAbs)
00016 return 0xff;
00017 else
00018 return (unsigned char)((val-_lowerAbs)*_ratio/_dist);
00019 }
00020
00021 void __fastcall TContrast::setLower(float val)
00022 {
00023 _lower = val;
00024 _dist = _upper - _lower;
00025 _lowerAbs = (int)(val*(float)_size);
00026 }
00027
00028 void __fastcall TContrast::setUpper(float val)
00029 {
00030 _upper = val;
00031 _dist = _upper - _lower;
00032 _upperAbs = (int)(val*(float)_size);
00033 }
00034
00035 #pragma package(smart_init)