36 int AnchorStepX,
int AnchorStepY,
42 int LastYCell = SizeY - AnchorStepY;
43 for (
int y = 0; y < LastYCell; y += AnchorStepY)
46 for (
int x = 0; x < SizeX; x += AnchorStepX)
48 TYPE StartValue = a_Array[Idx];
49 TYPE EndValue = a_Array[Idx + SizeX * AnchorStepY];
50 TYPE
Diff = EndValue - StartValue;
51 for (
int CellY = 1; CellY < AnchorStepY; CellY++)
53 a_Array[Idx + SizeX * CellY] = StartValue + Diff * CellY / AnchorStepY;
60 int LastXCell = SizeX - AnchorStepX;
61 for (
int y = 0; y < SizeY; y++)
64 for (
int x = 0; x < LastXCell; x += AnchorStepX)
66 TYPE StartValue = a_Array[Idx];
67 TYPE EndValue = a_Array[Idx + AnchorStepX];
68 TYPE
Diff = EndValue - StartValue;
69 for (
int CellX = 1; CellX < AnchorStepX; CellX++)
71 a_Array[Idx + CellX] = StartValue + CellX * Diff / AnchorStepX;
88 int a_SrcSizeX,
int a_SrcSizeY,
90 int a_UpscaleX,
int a_UpscaleY
95 const int MAX_UPSCALE_X = 129;
96 const int MAX_UPSCALE_Y = 129;
104 ASSERT(a_UpscaleX < MAX_UPSCALE_X);
105 ASSERT(a_UpscaleY < MAX_UPSCALE_Y);
108 TYPE RatioX[MAX_UPSCALE_X];
109 TYPE RatioY[MAX_UPSCALE_Y];
110 for (
int x = 0; x <= a_UpscaleX; x++)
112 RatioX[x] =
static_cast<TYPE
>(x) / a_UpscaleX;
114 for (
int y = 0; y <= a_UpscaleY; y++)
116 RatioY[y] =
static_cast<TYPE
>(y) / a_UpscaleY;
120 int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
122 int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
124 for (
int y = 0; y < (a_SrcSizeY - 1); y++)
126 int DstY = y * a_UpscaleY;
127 int idx = y * a_SrcSizeX;
128 for (
int x = 0; x < (a_SrcSizeX - 1); x++, idx++)
130 int DstX = x * a_UpscaleX;
131 TYPE LoXLoY = a_Src[idx];
132 TYPE LoXHiY = a_Src[idx + a_SrcSizeX];
133 TYPE HiXLoY = a_Src[idx + 1];
134 TYPE HiXHiY = a_Src[idx + 1 + a_SrcSizeX];
135 for (
int CellY = 0; CellY <= a_UpscaleY; CellY++)
137 int DestIdx = (DstY + CellY) * DstSizeX + DstX;
138 ASSERT(DestIdx + a_UpscaleX < DstSizeX * DstSizeY);
139 TYPE LoXInY = LoXLoY + (LoXHiY - LoXLoY) * RatioY[CellY];
140 TYPE HiXInY = HiXLoY + (HiXHiY - HiXLoY) * RatioY[CellY];
141 for (
int CellX = 0; CellX <= a_UpscaleX; CellX++, DestIdx++)
143 a_Dst[DestIdx] = LoXInY + (HiXInY - LoXInY) * RatioX[CellX];
160 int a_SrcSizeX,
int a_SrcSizeY,
int a_SrcSizeZ,
162 int a_UpscaleX,
int a_UpscaleY,
int a_UpscaleZ
167 const int MAX_UPSCALE_X = 128;
168 const int MAX_UPSCALE_Y = 128;
169 const int MAX_UPSCALE_Z = 128;
179 ASSERT(a_UpscaleX <= MAX_UPSCALE_X);
180 ASSERT(a_UpscaleY <= MAX_UPSCALE_Y);
181 ASSERT(a_UpscaleZ <= MAX_UPSCALE_Z);
184 TYPE RatioX[MAX_UPSCALE_X];
185 TYPE RatioY[MAX_UPSCALE_Y];
186 TYPE RatioZ[MAX_UPSCALE_Z];
187 for (
int x = 0; x <= a_UpscaleX; x++)
189 RatioX[x] =
static_cast<TYPE
>(x) / a_UpscaleX;
191 for (
int y = 0; y <= a_UpscaleY; y++)
193 RatioY[y] =
static_cast<TYPE
>(y) / a_UpscaleY;
195 for (
int z = 0; z <= a_UpscaleZ; z++)
197 RatioZ[z] =
static_cast<TYPE
>(z) / a_UpscaleZ;
201 int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
202 int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
204 int DstSizeZ = (a_SrcSizeZ - 1) * a_UpscaleZ + 1;
206 for (
int z = 0; z < (a_SrcSizeZ - 1); z++)
208 int DstZ = z * a_UpscaleZ;
209 for (
int y = 0; y < (a_SrcSizeY - 1); y++)
211 int DstY = y * a_UpscaleY;
212 int idx = y * a_SrcSizeX + z * a_SrcSizeX * a_SrcSizeY;
213 for (
int x = 0; x < (a_SrcSizeX - 1); x++, idx++)
215 int DstX = x * a_UpscaleX;
216 TYPE LoXLoYLoZ = a_Src[idx];
217 TYPE LoXLoYHiZ = a_Src[idx + a_SrcSizeX * a_SrcSizeY];
218 TYPE LoXHiYLoZ = a_Src[idx + a_SrcSizeX];
219 TYPE LoXHiYHiZ = a_Src[idx + a_SrcSizeX + a_SrcSizeX * a_SrcSizeY];
220 TYPE HiXLoYLoZ = a_Src[idx + 1];
221 TYPE HiXLoYHiZ = a_Src[idx + 1 + a_SrcSizeX * a_SrcSizeY];
222 TYPE HiXHiYLoZ = a_Src[idx + 1 + a_SrcSizeX];
223 TYPE HiXHiYHiZ = a_Src[idx + 1 + a_SrcSizeX + a_SrcSizeX * a_SrcSizeY];
224 for (
int CellZ = 0; CellZ <= a_UpscaleZ; CellZ++)
226 TYPE LoXLoYInZ = LoXLoYLoZ + (LoXLoYHiZ - LoXLoYLoZ) * RatioZ[CellZ];
227 TYPE LoXHiYInZ = LoXHiYLoZ + (LoXHiYHiZ - LoXHiYLoZ) * RatioZ[CellZ];
228 TYPE HiXLoYInZ = HiXLoYLoZ + (HiXLoYHiZ - HiXLoYLoZ) * RatioZ[CellZ];
229 TYPE HiXHiYInZ = HiXHiYLoZ + (HiXHiYHiZ - HiXHiYLoZ) * RatioZ[CellZ];
230 for (
int CellY = 0; CellY <= a_UpscaleY; CellY++)
232 int DestIdx = (DstZ + CellZ) * DstSizeX * DstSizeY + (DstY + CellY) * DstSizeX + DstX;
233 ASSERT(DestIdx + a_UpscaleX < DstSizeX * DstSizeY * DstSizeZ);
234 TYPE LoXInY = LoXLoYInZ + (LoXHiYInZ - LoXLoYInZ) * RatioY[CellY];
235 TYPE HiXInY = HiXLoYInZ + (HiXHiYInZ - HiXLoYInZ) * RatioY[CellY];
236 for (
int CellX = 0; CellX <= a_UpscaleX; CellX++, DestIdx++)
238 a_Dst[DestIdx] = LoXInY + (HiXInY - LoXInY) * RatioX[CellX];
void LinearUpscale2DArrayInPlace(TYPE *a_Array)
Linearly interpolates values in the array between the equidistant anchor points (upscales).
void LinearUpscale3DArray(TYPE *a_Src, int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, TYPE *a_Dst, int a_UpscaleX, int a_UpscaleY, int a_UpscaleZ)
Linearly interpolates values in the array between the equidistant anchor points (upscales).
void LinearUpscale2DArray(TYPE *a_Src, int a_SrcSizeX, int a_SrcSizeY, TYPE *a_Dst, int a_UpscaleX, int a_UpscaleY)
Linearly interpolates values in the array between the equidistant anchor points (upscales).
T Diff(T a_Val1, T a_Val2)