Converts the current image to the DestFormat format. ! \param DestFormat An enum of the desired output format. Any format values are accepted. \param DestType An enum of the desired output type. Any type values are accepted. \exception IL_ILLEGAL_OPERATION No currently bound image \exception IL_INVALID_CONVERSION DestFormat or DestType was an invalid identifier. \exception IL_OUT_OF_MEMOR
| 381 | \exception IL_OUT_OF_MEMORY Could not allocate enough memory. |
| 382 | \return Boolean value of failure or success*/ |
| 383 | ILboolean ILAPIENTRY ilConvertImage(ILenum DestFormat, ILenum DestType) |
| 384 | { |
| 385 | ILimage *Image, *pCurImage; |
| 386 | |
| 387 | if (iCurImage == NULL) { |
| 388 | ilSetError(IL_ILLEGAL_OPERATION); |
| 389 | return IL_FALSE; |
| 390 | } |
| 391 | |
| 392 | if (DestFormat == iCurImage->Format && DestType == iCurImage->Type) |
| 393 | return IL_TRUE; // No conversion needed. |
| 394 | |
| 395 | if (DestType == iCurImage->Type) { |
| 396 | if (iFastConvert(DestFormat)) { |
| 397 | iCurImage->Format = DestFormat; |
| 398 | return IL_TRUE; |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | if (ilIsEnabled(IL_USE_KEY_COLOUR)) { |
| 403 | ilAddAlphaKey(iCurImage); |
| 404 | } |
| 405 | |
| 406 | pCurImage = iCurImage; |
| 407 | while (pCurImage != NULL) |
| 408 | { |
| 409 | Image = iConvertImage(pCurImage, DestFormat, DestType); |
| 410 | if (Image == NULL) |
| 411 | return IL_FALSE; |
| 412 | |
| 413 | //ilCopyImageAttr(pCurImage, Image); // Destroys subimages. |
| 414 | |
| 415 | // We don't copy the colour profile here, since it stays the same. |
| 416 | // Same with the DXTC data. |
| 417 | pCurImage->Format = DestFormat; |
| 418 | pCurImage->Type = DestType; |
| 419 | pCurImage->Bpc = ilGetBpcType(DestType); |
| 420 | pCurImage->Bpp = ilGetBppFormat(DestFormat); |
| 421 | pCurImage->Bps = pCurImage->Width * pCurImage->Bpc * pCurImage->Bpp; |
| 422 | pCurImage->SizeOfPlane = pCurImage->Bps * pCurImage->Height; |
| 423 | pCurImage->SizeOfData = pCurImage->Depth * pCurImage->SizeOfPlane; |
| 424 | if (pCurImage->Pal.Palette && pCurImage->Pal.PalSize && pCurImage->Pal.PalType != IL_PAL_NONE) |
| 425 | ifree(pCurImage->Pal.Palette); |
| 426 | pCurImage->Pal.Palette = Image->Pal.Palette; |
| 427 | pCurImage->Pal.PalSize = Image->Pal.PalSize; |
| 428 | pCurImage->Pal.PalType = Image->Pal.PalType; |
| 429 | Image->Pal.Palette = NULL; |
| 430 | ifree(pCurImage->Data); |
| 431 | pCurImage->Data = Image->Data; |
| 432 | Image->Data = NULL; |
| 433 | ilCloseImage(Image); |
| 434 | |
| 435 | pCurImage = pCurImage->Next; |
| 436 | } |
| 437 | |
| 438 | return IL_TRUE; |
| 439 | } |
| 440 |
nothing calls this directly
no test coverage detected