MCPcopy Create free account
hub / github.com/DentonW/DevIL / iluScale1D_

Function iluScale1D_

DevIL/src-ILU/src/ilu_scale.cpp:191–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189
190
191ILimage *iluScale1D_(ILimage *Image, ILimage *Scaled, ILuint Width)
192{
193 ILuint x1, x2;
194 ILuint NewX1, NewX2, NewX3, x, c;
195 ILdouble ScaleX, t1, t2, f;
196 ILushort *ShortPtr, *SShortPtr;
197 ILuint *IntPtr, *SIntPtr;
198
199 if (Image == NULL) {
200 ilSetError(ILU_ILLEGAL_OPERATION);
201 return IL_FALSE;
202 }
203
204 ScaleX = (ILdouble)Width / Image->Width;
205
206 ShortPtr = (ILushort*)Image->Data;
207 SShortPtr = (ILushort*)Scaled->Data;
208 IntPtr = (ILuint*)Image->Data;
209 SIntPtr = (ILuint*)Scaled->Data;
210
211 if (iluFilter == ILU_NEAREST) {
212 switch (Image->Bpc)
213 {
214 case 1:
215 for (x = 0; x < Width; x++) {
216 NewX1 = x * Scaled->Bpp;
217 NewX2 = (ILuint)(x / ScaleX) * Image->Bpp;
218 for (c = 0; c < Scaled->Bpp; c++) {
219 Scaled->Data[NewX1 + c] = Image->Data[NewX2 + c];
220 }
221 }
222 break;
223 case 2:
224 for (x = 0; x < Width; x++) {
225 NewX1 = x * Scaled->Bpp;
226 NewX2 = (ILuint)(x / ScaleX) * Image->Bpp;
227 for (c = 0; c < Scaled->Bpp; c++) {
228 SShortPtr[NewX1 + c] = ShortPtr[NewX2 + c];
229 }
230 }
231 break;
232 case 4:
233 for (x = 0; x < Width; x++) {
234 NewX1 = x * Scaled->Bpp;
235 NewX2 = (ILuint)(x / ScaleX) * Image->Bpp;
236 for (c = 0; c < Scaled->Bpp; c++) {
237 SIntPtr[NewX1 + c] = IntPtr[NewX2 + c];
238 }
239 }
240 break;
241 }
242 }
243 else { // IL_LINEAR or IL_BILINEAR
244 switch (Image->Bpc)
245 {
246 case 1:
247 NewX3 = 0;
248 for (x = 0; x < Width; x++) {

Callers 1

ILAPIENTRY iluScale_Function · 0.85

Calls 1

ilSetErrorFunction · 0.85

Tested by

no test coverage detected