MCPcopy Create free account
hub / github.com/DentonW/DevIL / ILAPIENTRY ilConvertPal

Function ILAPIENTRY ilConvertPal

DevIL/src-IL/src/il_pal.cpp:844–872  ·  view source on GitHub ↗

Converts the current image to the DestFormat format.

Source from the content-addressed store, hash-verified

842
843//! Converts the current image to the DestFormat format.
844ILboolean 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.

Callers

nothing calls this directly

Calls 1

ilSetErrorFunction · 0.85

Tested by

no test coverage detected