24-bit color to 256 color's source

Hi folks!

I'm searching for a source to do a color-quantisation to display 24-bit
pictures on a 8-bit display.
There is a algorithm by "Heckbert" in C implemented. It is used in JPEG
C-source.
Is there a translation to PASCAL?

Waiting for answer.

Frank