nmpp
warpimg.h
1/*
2#include "nmpp.h"
3#define nmppiAT_BUFFER 1
4#define WARP_AT_BUFFER 2
5template<class T> class C_WarpImg
6{
7 bool isAllocated;
8 void (*pfFree32)(void*);
9public:
10 unsigned nWidth;
11 unsigned nHeight;
12 unsigned warpHeight;
13 T* pWarp;
14 unsigned nWarpSize;
15 T* pImg;
16 unsigned nImgSize;
17
18 C_WarpImg(unsigned width, unsigned height, unsigned border, void* (*malloc32)(unsigned ), void (*free32)(void*)){
19 nWidth=width;
20 nHeight=height;
21 nImgSize =width*height;
22 warpHeight=height+2*border;
23 nWarpSize=width*warpHeight;
24 pImg=0;
25 isAllocated=false;
26 pWarp=(T*)malloc32(nmppsSize32(pWarp,nWarpSize));
27 pfFree32=free32;
28 if (pWarp){
29 pImg=nmppsAddr_(pWarp,border*width);
30 isAllocated=true;
31 }
32 }
33
34 C_WarpImg(unsigned width, unsigned height, unsigned border, void* buffer, int mode=nmppiAT_BUFFER){
35 nWidth=width;
36 nHeight=height;
37 nImgSize =width*height;
38 warpHeight=height+2*border;
39 nWarpSize=width*warpHeight;
40
41 isAllocated=false;
42 if (mode==WARP_AT_BUFFER){
43 pWarp=(T*)buffer;
44 pImg=nmppsAddr_(pWarp,border*width);
45 }
46 if (mode==nmppiAT_BUFFER){
47 pImg =(T*)buffer;
48 pWarp=(T*)nmppsAddr_(pImg,-border*width);
49 }
50 }
51
52 T* addr(int x, int y){
53 return nmppsAddr_(pImg,y*nWidth+x);
54 }
55 T* end(){
56 return nmppsAddr_(pWarp,nWarpSize);
57 }
58
59 ~C_WarpImg(){
60 if (isAllocated){
61 pfFree32(pWarp);
62 }
63}
64
65
66};
67
68*/