| 515 | |
| 516 | |
| 517 | ILuint ILAPIENTRY ilCopyPixels(ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, void *Data) |
| 518 | { |
| 519 | void *Converted = NULL; |
| 520 | ILubyte *TempBuff = NULL; |
| 521 | ILuint SrcSize, DestSize; |
| 522 | |
| 523 | if (iCurImage == NULL) { |
| 524 | ilSetError(IL_ILLEGAL_OPERATION); |
| 525 | return 0; |
| 526 | } |
| 527 | DestSize = Width * Height * Depth * ilGetBppFormat(Format) * ilGetBpcType(Type); |
| 528 | if (DestSize == 0) { |
| 529 | return DestSize; |
| 530 | } |
| 531 | if (Data == NULL || Format == IL_COLOUR_INDEX) { |
| 532 | ilSetError(IL_INVALID_PARAM); |
| 533 | return 0; |
| 534 | } |
| 535 | SrcSize = Width * Height * Depth * iCurImage->Bpp * iCurImage->Bpc; |
| 536 | |
| 537 | if (Format == iCurImage->Format && Type == iCurImage->Type) { |
| 538 | TempBuff = (ILubyte*)Data; |
| 539 | } |
| 540 | else { |
| 541 | TempBuff = (ILubyte*)ialloc(SrcSize); |
| 542 | if (TempBuff == NULL) { |
| 543 | return 0; |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | if (YOff + Height <= 1) { |
| 548 | if (!ilCopyPixels1D(XOff, Width, TempBuff)) { |
| 549 | goto failed; |
| 550 | } |
| 551 | } |
| 552 | else if (ZOff + Depth <= 1) { |
| 553 | if (!ilCopyPixels2D(XOff, YOff, Width, Height, TempBuff)) { |
| 554 | goto failed; |
| 555 | } |
| 556 | } |
| 557 | else { |
| 558 | if (!ilCopyPixels3D(XOff, YOff, ZOff, Width, Height, Depth, TempBuff)) { |
| 559 | goto failed; |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | if (Format == iCurImage->Format && Type == iCurImage->Type) { |
| 564 | return DestSize; |
| 565 | } |
| 566 | |
| 567 | Converted = ilConvertBuffer(SrcSize, iCurImage->Format, Format, iCurImage->Type, Type, &iCurImage->Pal, TempBuff); |
| 568 | if (Converted == NULL) |
| 569 | goto failed; |
| 570 | |
| 571 | memcpy(Data, Converted, DestSize); |
| 572 | |
| 573 | ifree(Converted); |
| 574 | if (TempBuff != Data) |
nothing calls this directly
no test coverage detected