| 687 | |
| 688 | |
| 689 | ILboolean ilSetPixels3D(ILint XOff, ILint YOff, ILint ZOff, ILuint Width, ILuint Height, ILuint Depth, void *Data) |
| 690 | { |
| 691 | ILuint SkipX = 0, SkipY = 0, SkipZ = 0, c, NewBps, NewSizePlane, PixBpp; |
| 692 | ILint x, y, z, NewW, NewH, NewD; |
| 693 | ILubyte *Temp = (ILubyte*)Data, *TempData = iCurImage->Data; |
| 694 | |
| 695 | if (ilIsEnabled(IL_ORIGIN_SET)) { |
| 696 | if ((ILenum)ilGetInteger(IL_ORIGIN_MODE) != iCurImage->Origin) { |
| 697 | TempData = iGetFlipped(iCurImage); |
| 698 | if (TempData == NULL) |
| 699 | return IL_FALSE; |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | PixBpp = iCurImage->Bpp * iCurImage->Bpc; |
| 704 | |
| 705 | if (XOff < 0) { |
| 706 | SkipX = abs(XOff); |
| 707 | XOff = 0; |
| 708 | } |
| 709 | if (YOff < 0) { |
| 710 | SkipY = abs(YOff); |
| 711 | YOff = 0; |
| 712 | } |
| 713 | if (ZOff < 0) { |
| 714 | SkipZ = abs(ZOff); |
| 715 | ZOff = 0; |
| 716 | } |
| 717 | |
| 718 | if (iCurImage->Width < XOff + Width) |
| 719 | NewW = iCurImage->Width - XOff; |
| 720 | else |
| 721 | NewW = Width; |
| 722 | NewBps = Width * PixBpp; |
| 723 | |
| 724 | if (iCurImage->Height < YOff + Height) |
| 725 | NewH = iCurImage->Height - YOff; |
| 726 | else |
| 727 | NewH = Height; |
| 728 | |
| 729 | if (iCurImage->Depth < ZOff + Depth) |
| 730 | NewD = iCurImage->Depth - ZOff; |
| 731 | else |
| 732 | NewD = Depth; |
| 733 | NewSizePlane = NewBps * Height; |
| 734 | |
| 735 | NewW -= SkipX; |
| 736 | NewH -= SkipY; |
| 737 | NewD -= SkipZ; |
| 738 | |
| 739 | for (z = 0; z < NewD; z++) { |
| 740 | for (y = 0; y < NewH; y++) { |
| 741 | for (x = 0; x < NewW; x++) { |
| 742 | for (c = 0; c < PixBpp; c++) { |
| 743 | TempData[(z + ZOff) * iCurImage->SizeOfPlane + (y + YOff) * iCurImage->Bps + (x + XOff) * PixBpp + c] = |
| 744 | Temp[(z + SkipZ) * NewSizePlane + (y + SkipY) * NewBps + (x + SkipX) * PixBpp + c]; |
| 745 | } |
| 746 | } |
no outgoing calls
no test coverage detected