28 #ifndef OGREIMAGERESAMPLER_H
29 #define OGREIMAGERESAMPLER_H
70 uint64 sz_48 = (stepz >> 1) - 1;
71 for (
size_t z = dst.
front; z < dst.
back; z++, sz_48 += stepz) {
72 size_t srczoff = (size_t)(sz_48 >> 48) * src.
slicePitch;
74 uint64 sy_48 = (stepy >> 1) - 1;
75 for (
size_t y = dst.
top; y < dst.
bottom; y++, sy_48 += stepy) {
76 size_t srcyoff = (size_t)(sy_48 >> 48) * src.
rowPitch;
78 uint64 sx_48 = (stepx >> 1) - 1;
79 for (
size_t x = dst.
left; x < dst.
right; x++, sx_48 += stepx) {
80 uchar* psrc = srcdata +
81 elemsize*((size_t)(sx_48 >> 48) + srcyoff + srczoff);
82 memcpy(pdst, psrc, elemsize);
111 uint64 sz_48 = (stepz >> 1) - 1;
112 for (
size_t z = dst.
front; z < dst.
back; z++, sz_48+=stepz) {
117 unsigned int temp =
static_cast<unsigned int>(sz_48 >> 32);
119 temp = (temp > 0x8000)? temp - 0x8000 : 0;
122 float szf = (temp & 0xFFFF) / 65536.f;
124 uint64 sy_48 = (stepy >> 1) - 1;
125 for (
size_t y = dst.
top; y < dst.
bottom; y++, sy_48+=stepy) {
126 temp =
static_cast<unsigned int>(sy_48 >> 32);
127 temp = (temp > 0x8000)? temp - 0x8000 : 0;
130 float syf = (temp & 0xFFFF) / 65536.f;
132 uint64 sx_48 = (stepx >> 1) - 1;
133 for (
size_t x = dst.
left; x < dst.
right; x++, sx_48+=stepx) {
134 temp =
static_cast<unsigned int>(sx_48 >> 32);
135 temp = (temp > 0x8000)? temp - 0x8000 : 0;
138 float sxf = (temp & 0xFFFF) / 65536.f;
143 #define UNPACK(dst,x,y,z) PixelUtil::unpackColour(&dst, src.format, \
144 srcdata + srcelemsize*((x)+(y)*src.rowPitch+(z)*src.slicePitch))
153 x1y1z1 * ((1.0f - sxf)*(1.0f - syf)*(1.0f - szf)) +
154 x2y1z1 * ( sxf *(1.0f - syf)*(1.0f - szf)) +
155 x1y2z1 * ((1.0f - sxf)* syf *(1.0f - szf)) +
156 x2y2z1 * ( sxf * syf *(1.0f - szf)) +
157 x1y1z2 * ((1.0f - sxf)*(1.0f - syf)* szf ) +
158 x2y1z2 * ( sxf *(1.0f - syf)* szf ) +
159 x1y2z2 * ((1.0f - sxf)* syf * szf ) +
160 x2y2z2 * ( sxf * syf * szf );
195 uint64 sz_48 = (stepz >> 1) - 1;
196 for (
size_t z = dst.
front; z < dst.
back; z++, sz_48+=stepz) {
201 unsigned int temp =
static_cast<unsigned int>(sz_48 >> 32);
203 temp = (temp > 0x8000)? temp - 0x8000 : 0;
206 float szf = (temp & 0xFFFF) / 65536.f;
208 uint64 sy_48 = (stepy >> 1) - 1;
209 for (
size_t y = dst.
top; y < dst.
bottom; y++, sy_48+=stepy) {
210 temp =
static_cast<unsigned int>(sy_48 >> 32);
211 temp = (temp > 0x8000)? temp - 0x8000 : 0;
214 float syf = (temp & 0xFFFF) / 65536.f;
216 uint64 sx_48 = (stepx >> 1) - 1;
217 for (
size_t x = dst.
left; x < dst.
right; x++, sx_48+=stepx) {
218 temp =
static_cast<unsigned int>(sx_48 >> 32);
219 temp = (temp > 0x8000)? temp - 0x8000 : 0;
222 float sxf = (temp & 0xFFFF) / 65536.f;
225 float accum[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
227 #define ACCUM3(x,y,z,factor) \
228 { float f = factor; \
229 size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
230 accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
231 accum[2]+=srcdata[off+2]*f; }
233 #define ACCUM4(x,y,z,factor) \
234 { float f = factor; \
235 size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
236 accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
237 accum[2]+=srcdata[off+2]*f; accum[3]+=srcdata[off+3]*f; }
239 if (srcchannels == 3 || dstchannels == 3) {
241 ACCUM3(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
242 ACCUM3(sx2,sy1,sz1, sxf *(1.0f-syf)*(1.0f-szf));
243 ACCUM3(sx1,sy2,sz1,(1.0f-sxf)* syf *(1.0f-szf));
244 ACCUM3(sx2,sy2,sz1, sxf * syf *(1.0f-szf));
245 ACCUM3(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)* szf );
246 ACCUM3(sx2,sy1,sz2, sxf *(1.0f-syf)* szf );
247 ACCUM3(sx1,sy2,sz2,(1.0f-sxf)* syf * szf );
248 ACCUM3(sx2,sy2,sz2, sxf * syf * szf );
252 ACCUM4(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
253 ACCUM4(sx2,sy1,sz1, sxf *(1.0f-syf)*(1.0f-szf));
254 ACCUM4(sx1,sy2,sz1,(1.0f-sxf)* syf *(1.0f-szf));
255 ACCUM4(sx2,sy2,sz1, sxf * syf *(1.0f-szf));
256 ACCUM4(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)* szf );
257 ACCUM4(sx2,sy1,sz2, sxf *(1.0f-syf)* szf );
258 ACCUM4(sx1,sy2,sz2,(1.0f-sxf)* syf * szf );
259 ACCUM4(sx2,sy2,sz2, sxf * syf * szf );
262 memcpy(pdst, accum,
sizeof(
float)*dstchannels);
302 uint64 sy_48 = (stepy >> 1) - 1;
303 for (
size_t y = dst.
top; y < dst.
bottom; y++, sy_48+=stepy) {
308 unsigned int temp =
static_cast<unsigned int>(sy_48 >> 36);
309 temp = (temp > 0x800)? temp - 0x800: 0;
310 unsigned int syf = temp & 0xFFF;
316 uint64 sx_48 = (stepx >> 1) - 1;
317 for (
size_t x = dst.
left; x < dst.
right; x++, sx_48+=stepx) {
318 temp =
static_cast<unsigned int>(sx_48 >> 36);
319 temp = (temp > 0x800)? temp - 0x800 : 0;
320 unsigned int sxf = temp & 0xFFF;
324 unsigned int sxfsyf = sxf*syf;
325 for (
unsigned int k = 0; k < channels; k++) {
327 srcdata[(sx1 + syoff1)*channels+k]*(0x1000000-(sxf<<12)-(syf<<12)+sxfsyf) +
328 srcdata[(sx2 + syoff1)*channels+k]*((sxf<<12)-sxfsyf) +
329 srcdata[(sx1 + syoff2)*channels+k]*((syf<<12)-sxfsyf) +
330 srcdata[(sx2 + syoff2)*channels+k]*sxfsyf;
333 *pdst++ =
static_cast<uchar>((accum + 0x800000) >> 24);
static void scale(const PixelBox &src, const PixelBox &dst)
#define ACCUM3(x, y, z, factor)
size_t rowPitch
Number of elements between the leftmost pixel of one row and the left pixel of the next...
static void scale(const PixelBox &src, const PixelBox &dst)
Class representing colour.
size_t getSliceSkip() const
Get the number of elements between one past the right bottom pixel of one slice and the left top pixe...
uint32 getDepth() const
Get the depth of this box.
#define ACCUM4(x, y, z, factor)
uint32 getWidth() const
Get the width of this box.
static void scale(const PixelBox &src, const PixelBox &dst)
PixelFormat format
The pixel format.
void * getTopLeftFrontPixelPtr() const
Return a data pointer pointing to top left front pixel of the pixel box.
unsigned char uchar
In order to avoid finger-aches :)
unsigned long long uint64
uint32 getHeight() const
Get the height of this box.
size_t slicePitch
Number of elements between the top left pixel of one (depth) slice and the top left pixel of the next...
#define UNPACK(dst, x, y, z)
static void scale(const PixelBox &src, const PixelBox &dst)
static size_t getNumElemBytes(PixelFormat format)
Returns the size in bytes of an element of the given pixel format.
static void packColour(const ColourValue &colour, const PixelFormat pf, void *dest)
Pack a colour value to memory.
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
size_t getRowSkip() const
Get the number of elements between one past the rightmost pixel of one row and the leftmost pixel of ...