| 630 | |
| 631 | |
| 632 | ILboolean ilSetPixels2D(ILint XOff, ILint YOff, ILuint Width, ILuint Height, void *Data) |
| 633 | { |
| 634 | ILuint c, SkipX = 0, SkipY = 0, NewBps, PixBpp; |
| 635 | ILint x, y, NewWidth, NewHeight; |
| 636 | ILubyte *Temp = (ILubyte*)Data, *TempData = iCurImage->Data; |
| 637 | |
| 638 | if (ilIsEnabled(IL_ORIGIN_SET)) { |
| 639 | if ((ILenum)ilGetInteger(IL_ORIGIN_MODE) != iCurImage->Origin) { |
| 640 | TempData = iGetFlipped(iCurImage); |
| 641 | if (TempData == NULL) |
| 642 | return IL_FALSE; |
| 643 | } |
| 644 | } |
| 645 | |
| 646 | PixBpp = iCurImage->Bpp * iCurImage->Bpc; |
| 647 | |
| 648 | if (XOff < 0) { |
| 649 | SkipX = abs(XOff); |
| 650 | XOff = 0; |
| 651 | } |
| 652 | if (YOff < 0) { |
| 653 | SkipY = abs(YOff); |
| 654 | YOff = 0; |
| 655 | } |
| 656 | |
| 657 | if (iCurImage->Width < XOff + Width) |
| 658 | NewWidth = iCurImage->Width - XOff; |
| 659 | else |
| 660 | NewWidth = Width; |
| 661 | NewBps = Width * PixBpp; |
| 662 | |
| 663 | if (iCurImage->Height < YOff + Height) |
| 664 | NewHeight = iCurImage->Height - YOff; |
| 665 | else |
| 666 | NewHeight = Height; |
| 667 | |
| 668 | NewWidth -= SkipX; |
| 669 | NewHeight -= SkipY; |
| 670 | |
| 671 | for (y = 0; y < NewHeight; y++) { |
| 672 | for (x = 0; x < NewWidth; x++) { |
| 673 | for (c = 0; c < PixBpp; c++) { |
| 674 | TempData[(y + YOff) * iCurImage->Bps + (x + XOff) * PixBpp + c] = |
| 675 | Temp[(y + SkipY) * NewBps + (x + SkipX) * PixBpp + c]; |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | if (TempData != iCurImage->Data) { |
| 681 | ifree(iCurImage->Data); |
| 682 | iCurImage->Data = TempData; |
| 683 | } |
| 684 | |
| 685 | return IL_TRUE; |
| 686 | } |
| 687 | |
| 688 | |
| 689 | ILboolean ilSetPixels3D(ILint XOff, ILint YOff, ILint ZOff, ILuint Width, ILuint Height, ILuint Depth, void *Data) |
no outgoing calls
no test coverage detected