Copies a 3d block of pixels to the buffer pointed to by Data.
| 461 | |
| 462 | // Copies a 3d block of pixels to the buffer pointed to by Data. |
| 463 | ILboolean ilCopyPixels3D(ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth, void *Data) |
| 464 | { |
| 465 | ILuint x, y, z, c, NewBps, DataBps, NewSizePlane, NewH, NewD, NewXOff, PixBpp; |
| 466 | ILubyte *Temp = (ILubyte*)Data, *TempData = iCurImage->Data; |
| 467 | |
| 468 | if (ilIsEnabled(IL_ORIGIN_SET)) { |
| 469 | if ((ILenum)ilGetInteger(IL_ORIGIN_MODE) != iCurImage->Origin) { |
| 470 | TempData = iGetFlipped(iCurImage); |
| 471 | if (TempData == NULL) |
| 472 | return IL_FALSE; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | PixBpp = iCurImage->Bpp * iCurImage->Bpc; |
| 477 | |
| 478 | if (iCurImage->Width < XOff + Width) |
| 479 | NewBps = (iCurImage->Width - XOff) * PixBpp; |
| 480 | else |
| 481 | NewBps = Width * PixBpp; |
| 482 | |
| 483 | if (iCurImage->Height < YOff + Height) |
| 484 | NewH = iCurImage->Height - YOff; |
| 485 | else |
| 486 | NewH = Height; |
| 487 | |
| 488 | if (iCurImage->Depth < ZOff + Depth) |
| 489 | NewD = iCurImage->Depth - ZOff; |
| 490 | else |
| 491 | NewD = Depth; |
| 492 | |
| 493 | DataBps = Width * PixBpp; |
| 494 | NewSizePlane = NewBps * NewH; |
| 495 | |
| 496 | NewXOff = XOff * PixBpp; |
| 497 | |
| 498 | for (z = 0; z < NewD; z++) { |
| 499 | for (y = 0; y < NewH; y++) { |
| 500 | for (x = 0; x < NewBps; x += PixBpp) { |
| 501 | for (c = 0; c < PixBpp; c++) { |
| 502 | Temp[z * NewSizePlane + y * DataBps + x + c] = |
| 503 | TempData[(z + ZOff) * iCurImage->SizeOfPlane + (y + YOff) * iCurImage->Bps + x + NewXOff + c]; |
| 504 | //TempData[(z + ZOff) * iCurImage->SizeOfPlane + (y + YOff) * iCurImage->Bps + (x + XOff) * iCurImage->Bpp + c]; |
| 505 | } |
| 506 | } |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | if (TempData != iCurImage->Data) |
| 511 | ifree(TempData); |
| 512 | |
| 513 | return IL_TRUE; |
| 514 | } |
| 515 | |
| 516 | |
| 517 | ILuint ILAPIENTRY ilCopyPixels(ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, void *Data) |
no outgoing calls
no test coverage detected