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

Function EndianSwapData

DevIL/src-IL/src/il_endian.cpp:285–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285void EndianSwapData(void *_Image)
286{
287 ILuint i;
288 ILubyte *temp, *s, *d;
289 ILushort *ShortS, *ShortD;
290 ILuint *IntS, *IntD;
291 ILfloat *FltS, *FltD;
292 ILdouble *DblS, *DblD;
293
294 ILimage *Image = (ILimage*)_Image;
295
296 switch (Image->Type) {
297 case IL_BYTE:
298 case IL_UNSIGNED_BYTE:
299 switch (Image->Bpp) {
300 case 3:
301 temp = (ILubyte*)ialloc(Image->SizeOfData);
302 if (temp == NULL)
303 return;
304 s = Image->Data;
305 d = temp;
306
307 for( i = Image->Width * Image->Height; i > 0; i-- ) {
308 *d++ = *(s+2);
309 *d++ = *(s+1);
310 *d++ = *s;
311 s += 3;
312 }
313
314 ifree(Image->Data);
315 Image->Data = temp;
316 break;
317
318 case 4:
319 temp = (ILubyte*)ialloc(Image->SizeOfData);
320 if (temp == NULL)
321 return;
322 s = Image->Data;
323 d = temp;
324
325 for (i = Image->Width * Image->Height; i > 0; i--) {
326 *d++ = *(s+3);
327 *d++ = *(s+2);
328 *d++ = *(s+1);
329 *d++ = *s;
330 s += 4;
331 }
332
333 ifree(Image->Data);
334 Image->Data = temp;
335 break;
336 }
337 break;
338
339 case IL_SHORT:
340 case IL_UNSIGNED_SHORT:
341 switch (Image->Bpp) {
342 case 3:

Callers 1

iLoadTiffInternalFunction · 0.85

Calls 4

iSwapUShortFunction · 0.85
iSwapUIntFunction · 0.85
iSwapFloatFunction · 0.85
iSwapDoubleFunction · 0.85

Tested by

no test coverage detected