| 34 | |
| 35 | |
| 36 | ILboolean ILAPIENTRY iluScale(ILuint Width, ILuint Height, ILuint Depth) |
| 37 | { |
| 38 | ILimage *Temp; |
| 39 | ILboolean UsePal; |
| 40 | ILenum PalType; |
| 41 | ILenum Origin; |
| 42 | |
| 43 | iluCurImage = ilGetCurImage(); |
| 44 | if (iluCurImage == NULL) { |
| 45 | ilSetError(ILU_ILLEGAL_OPERATION); |
| 46 | return IL_FALSE; |
| 47 | } |
| 48 | |
| 49 | if (iluCurImage->Width == Width && iluCurImage->Height == Height && iluCurImage->Depth == Depth) |
| 50 | return IL_TRUE; |
| 51 | |
| 52 | // A parameter of 0 is not valid. Let's just assume that the user wanted a value of 1 instead. |
| 53 | if (Width == 0) Width = 1; |
| 54 | if (Height == 0) Height = 1; |
| 55 | if (Depth == 0) Depth = 1; |
| 56 | |
| 57 | if ((iluCurImage->Width<Width) || (iluCurImage->Height<Height)) // only do special scale if there is some zoom? |
| 58 | { |
| 59 | switch (iluFilter) |
| 60 | { |
| 61 | case ILU_SCALE_BOX: |
| 62 | case ILU_SCALE_TRIANGLE: |
| 63 | case ILU_SCALE_BELL: |
| 64 | case ILU_SCALE_BSPLINE: |
| 65 | case ILU_SCALE_LANCZOS3: |
| 66 | case ILU_SCALE_MITCHELL: |
| 67 | |
| 68 | iluCurImage = ilGetCurImage(); |
| 69 | if (iluCurImage == NULL) { |
| 70 | ilSetError(ILU_ILLEGAL_OPERATION); |
| 71 | return IL_FALSE; |
| 72 | } |
| 73 | |
| 74 | // Not supported yet. |
| 75 | if (iluCurImage->Type != IL_UNSIGNED_BYTE || |
| 76 | iluCurImage->Format == IL_COLOUR_INDEX || |
| 77 | iluCurImage->Depth > 1) { |
| 78 | ilSetError(ILU_ILLEGAL_OPERATION); |
| 79 | return IL_FALSE; |
| 80 | } |
| 81 | |
| 82 | if (iluCurImage->Width > Width) // shrink width first |
| 83 | { |
| 84 | Origin = iluCurImage->Origin; |
| 85 | Temp = iluScale_(iluCurImage, Width, iluCurImage->Height, iluCurImage->Depth); |
| 86 | if (Temp != NULL) { |
| 87 | if (!ilTexImage(Temp->Width, Temp->Height, Temp->Depth, Temp->Bpp, Temp->Format, Temp->Type, Temp->Data)) { |
| 88 | ilCloseImage(Temp); |
| 89 | return IL_FALSE; |
| 90 | } |
| 91 | iluCurImage->Origin = Origin; |
| 92 | ilCloseImage(Temp); |
| 93 | } |
nothing calls this directly
no test coverage detected