quantize

Converts true color to an indexed image. It uses palette as the starting point, adding entries until maxColors as needed. If palette is null, it creates a whole new palette.

After quantizing the image, it applies a dithering algorithm.

This is not written for speed.

@safe
quantize
(
,
Color[] palette = null
,
in int maxColors = 256
)
in { assert (maxColors <= 256); }

Meta