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

Function ilCopyPixels2D

DevIL/src-IL/src/il_manip.cpp:418–459  ·  view source on GitHub ↗

Copies a 2d block of pixels to the buffer pointed to by Data.

Source from the content-addressed store, hash-verified

416
417// Copies a 2d block of pixels to the buffer pointed to by Data.
418ILboolean ilCopyPixels2D(ILuint XOff, ILuint YOff, ILuint Width, ILuint Height, void *Data)
419{
420 ILuint x, y, c, NewBps, DataBps, NewXOff, NewHeight, PixBpp;
421 ILubyte *Temp = (ILubyte*)Data, *TempData = iCurImage->Data;
422
423 if (ilIsEnabled(IL_ORIGIN_SET)) {
424 if ((ILenum)ilGetInteger(IL_ORIGIN_MODE) != iCurImage->Origin) {
425 TempData = iGetFlipped(iCurImage);
426 if (TempData == NULL)
427 return IL_FALSE;
428 }
429 }
430
431 PixBpp = iCurImage->Bpp * iCurImage->Bpc;
432
433 if (iCurImage->Width < XOff + Width)
434 NewBps = (iCurImage->Width - XOff) * PixBpp;
435 else
436 NewBps = Width * PixBpp;
437
438 if (iCurImage->Height < YOff + Height)
439 NewHeight = iCurImage->Height - YOff;
440 else
441 NewHeight = Height;
442
443 DataBps = Width * PixBpp;
444 NewXOff = XOff * PixBpp;
445
446 for (y = 0; y < NewHeight; y++) {
447 for (x = 0; x < NewBps; x += PixBpp) {
448 for (c = 0; c < PixBpp; c++) {
449 Temp[y * DataBps + x + c] =
450 TempData[(y + YOff) * iCurImage->Bps + x + NewXOff + c];
451 }
452 }
453 }
454
455 if (TempData != iCurImage->Data)
456 ifree(TempData);
457
458 return IL_TRUE;
459}
460
461
462// Copies a 3d block of pixels to the buffer pointed to by Data.

Callers 1

ILAPIENTRY ilCopyPixelsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected