function TidyPalette(const palette: TArrayOfColor32; var colorFrequency: TArrayOfInteger; minimumFrac: double): TArrayOfColor32;

Given that each palette entry will color a specific fraction of an image, TidyPalette removes palette entries whose colorFrequency is less that a minimumFrac fraction of this average palette fraction. It assumes that CreatePaletteEx has been called previously, and the returned colorFrequency parameter from that function is the same one passed to this function. colorFrequency will also be updated to properly reflect the new palette.

For example, ignoring transparent pixels, given a palette with 256 entries, then the average color frequency (AvFreq) for each palette entry will be

AvFreq = Total Pixels / 256
. So if minimumFrac = 0.02 (or 1/50), then TidyPalette will remove palette entries with a colorFrequency that's less than 1/50th of AvFreq.

See Also

CreatePaletteEx, TrimPalette