Converts the current image to the DestFormat format.
| 842 | |
| 843 | //! Converts the current image to the DestFormat format. |
| 844 | ILboolean ILAPIENTRY ilConvertPal(ILenum DestFormat) |
| 845 | { |
| 846 | ILpal *Pal; |
| 847 | |
| 848 | if (iCurImage == NULL || iCurImage->Pal.Palette == NULL || |
| 849 | iCurImage->Pal.PalSize == 0 || iCurImage->Pal.PalType == IL_PAL_NONE) { |
| 850 | ilSetError(IL_ILLEGAL_OPERATION); |
| 851 | return IL_FALSE; |
| 852 | } |
| 853 | |
| 854 | Pal = iConvertPal(&iCurImage->Pal, DestFormat); |
| 855 | if (Pal == NULL) |
| 856 | return IL_FALSE; |
| 857 | |
| 858 | ifree(iCurImage->Pal.Palette); |
| 859 | iCurImage->Pal.PalSize = Pal->PalSize; |
| 860 | iCurImage->Pal.PalType = Pal->PalType; |
| 861 | |
| 862 | iCurImage->Pal.Palette = (ILubyte*)ialloc(Pal->PalSize); |
| 863 | if (iCurImage->Pal.Palette == NULL) { |
| 864 | return IL_FALSE; |
| 865 | } |
| 866 | memcpy(iCurImage->Pal.Palette, Pal->Palette, Pal->PalSize); |
| 867 | |
| 868 | ifree(Pal->Palette); |
| 869 | ifree(Pal); |
| 870 | |
| 871 | return IL_TRUE; |
| 872 | } |
| 873 | |
| 874 | |
| 875 | // Sets the current palette. |
nothing calls this directly
no test coverage detected