#include <HxImgFtorRgb2d.h>
Inheritance diagram for HxImgFtorRgb2d::
Public Types | |
typedef HxImgFtorRgbKey | KeyType |
The key type of this class. More... | |
Public Methods | |
HxImgFtorRgb2d () | |
Constructor. More... | |
virtual | ~HxImgFtorRgb2d () |
Destructor. More... | |
Protected Methods | |
virtual void | doIt (ImgDataPtrType ptr, HxSizes size, HxTagList &tags, HxImgFtorDescription *=0) |
The actual operation. More... |
|
The key type of this class.
Reimplemented from HxImgFtorI1Cast. |
|
Constructor.
00019 : HxImgFtorI1Cast<ImgSigT>(HxImgFtorRgbKey(HxClassName<ImgSigT>(), 00020 HxClassName<RgbT>())) 00021 { 00022 #ifdef CD_TRACE 00023 HxEnvironment::instance()->outputStream() 00024 << "HxImgFtorRgb2d::HxImgFtorRgb2d()" << STD_ENDL; 00025 #endif 00026 static HxRegKey* surKey 00027 = HxRegistry::instance().insertKey("/imagefunctortable/rgb"); 00028 00029 HxRegKey* k = surKey->insertKey(HxClassName<RgbT>()); 00030 k = k->insertKey("imagetype"); 00031 k->insertValue( 00032 HxClassName<ImgSigT>(), HxRegData(HxClassName<ImgSigT>())); 00033 } |
|
Destructor.
00037 { 00038 #ifdef CD_TRACE 00039 HxEnvironment::instance()->outputStream() 00040 << "HxImgFtorRgb2d::~HxImgFtorRgb2d()" << STD_ENDL; 00041 #endif 00042 } |
|
The actual operation.
Reimplemented from HxImgFtorI1Cast.
00048 { 00049 int* pixels = HxGetTag<int*>(tags, "pixels"); 00050 int resWidth = HxGetTag<int>(tags, "resWidth"); 00051 int resHeight = HxGetTag<int>(tags, "resHeight"); 00052 HxGeoIntType gi = HxGetTag<HxGeoIntType>(tags, "gi"); 00053 int width = size.x(); 00054 int height = size.y(); 00055 00056 RgbT rgbOp(tags); 00057 00058 if (((resWidth == -1) && (resHeight == -1)) || 00059 ((resWidth == width) && (resHeight == height))) { 00060 int nPix = width * height; 00061 ImgDataPtrType p = ptr; 00062 while (--nPix >= 0) { 00063 *pixels++ = rgbOp.doIt(p.read()); 00064 p.incX(); 00065 } 00066 return; 00067 } 00068 00069 double sx = (double) width / resWidth; 00070 double sy = (double) height / resHeight; 00071 if (gi == NEAREST) { 00072 for (int y=0 ; y<resHeight ; y++) { 00073 for (int x=0 ; x<resWidth ; x++) { 00074 ImgDataPtrType p = ptr; 00075 p.incXYZ((int) (sx * x + 0.5), (int) (sy * y + 0.5), 0); 00076 *pixels++ = rgbOp.doIt(p.read()); 00077 } 00078 } 00079 return; 00080 } 00081 00082 TYPENAME ImgSigT::ArithTypeDouble result; 00083 for (int y=0 ; y<resHeight ; y++) { 00084 for (int x=0 ; x<resWidth ; x++) { 00085 result = HxFunc2dSample(ptr, result, sx * x, sy * y, 0, gi); 00086 *pixels++ = rgbOp.doItDouble(result); 00087 } 00088 } 00089 } |