#include "HxFuncRgbOp2d.h"
#include "HxCategories.h"
#include "HxFuncs2d.h"
Functions | |
template<class DataPtrT, class RgbT> void | HxFuncRgbOp2d (DataPtrT imPtr, HxSizes imSize, int *pixels, int resWidth, int resHeight, HxGeoIntType gi, RgbT &rgb) |
Function for RgbOp2d. More... |
|
Function for RgbOp2d.
00025 { 00026 int width = imSize.x(); 00027 int height = imSize.y(); 00028 00029 00030 if (((resWidth == -1) && (resHeight == -1)) || 00031 ((resWidth == width) && (resHeight == height))) { 00032 int nPix = width * height; 00033 DataPtrT p = imPtr; 00034 while (--nPix >= 0) { 00035 *pixels++ = rgb.doIt(p.read()); 00036 p.incX(); 00037 } 00038 return; 00039 } 00040 00041 double sx = (double) width / resWidth; 00042 double sy = (double) height / resHeight; 00043 if (gi == NEAREST) { 00044 for (int y=0 ; y<resHeight ; y++) { 00045 for (int x=0 ; x<resWidth ; x++) { 00046 DataPtrT p = imPtr; 00047 p.incXYZ((int) (sx * x + 0.5), (int) (sy * y + 0.5), 0); 00048 *pixels++ = rgb.doIt(p.read()); 00049 } 00050 } 00051 return; 00052 } 00053 00054 typedef typename RgbT::ArithTypeDouble ArithTypeDouble; 00055 ArithTypeDouble result; 00056 for (int y=0 ; y<resHeight ; y++) { 00057 for (int x=0 ; x<resWidth ; x++) { 00058 result = HxFunc2dSample(imPtr, result, sx * x, sy * y, 0, gi); 00059 *pixels++ = rgb.doItDouble(result); 00060 } 00061 } 00062 } |