Main Page   Class Overview   Pixels   Images   Geometry   Quick Index  

HxImgFtorRgb2d Class Template Reference

Instantiation of generic algorithm for display of 2d images. More...

#include <HxImgFtorRgb2d.h>

Inheritance diagram for HxImgFtorRgb2d::

HxImgFtorI1Cast HxImgFtorI1 HxImgFunctor List of all members.

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...


Detailed Description

template<class ImgSigT, class RgbT>
class HxImgFtorRgb2d< ImgSigT, RgbT >

Instantiation of generic algorithm for display of 2d images.


Member Typedef Documentation

template<class ImgSigT, class RgbT>
typedef HxImgFtorRgbKey HxImgFtorRgb2d::KeyType
 

The key type of this class.

Reimplemented from HxImgFtorI1Cast.


Constructor & Destructor Documentation

template<class ImgSigT, class RgbT>
HxImgFtorRgb2d< ImgSigT, RgbT >::HxImgFtorRgb2d   [inline]
 

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 }

template<class ImgSigT, class RgbT>
HxImgFtorRgb2d< ImgSigT, RgbT >::~HxImgFtorRgb2d   [virtual]
 

Destructor.

00037 {
00038 #ifdef CD_TRACE
00039     HxEnvironment::instance()->outputStream()
00040         << "HxImgFtorRgb2d::~HxImgFtorRgb2d()" << STD_ENDL;
00041 #endif
00042 }


Member Function Documentation

template<class ImgSigT, class RgbT>
void HxImgFtorRgb2d< ImgSigT, RgbT >::doIt ImgDataPtrType    ptr,
HxSizes    size,
HxTagList   tags,
HxImgFtorDescription   description = 0
[protected, virtual]
 

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 }


The documentation for this class was generated from the following files:
Generated on Tue Jan 8 13:59:30 2002 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001