Maps image to existing palette producing image in ifIndex8 format.
function MapImageToPalette(var Image: TImageData; Pal: PPalette32; Entries: LongInt): Boolean;
Imaging (at line 187)
Pal must be allocated to at least Entries * SizeOf(TColor32Rec) bytes. As resulting image is in 8bit indexed format Entries must be lower or equal to 256.