Quantizer.h file
Namespaces
- namespace Jazz2
- Root namespace of Jazz² Resurrection.
- namespace Jazz2::Editor
Classes
- class Jazz2::Editor::PaletteMapper
- Finds the entries of a palette closest to colors, and remembers them.
Functions
-
auto BuildPalette(Death::
Containers:: ArrayView<const std:: uint32_t> colors, std:: uint32_t(&palette)[256], const bool(&locked)[256], Death:: Containers:: Function<bool(float)>&& progress = {}) -> std:: int32_t - Picks colors for the free entries of a palette, so the colors of an image look as close as they can.
Function documentation
std:: int32_t BuildPalette(Death:: Containers:: ArrayView<const std:: uint32_t> colors,
std:: uint32_t(&palette)[256],
const bool(&locked)[256],
Death:: Containers:: Function<bool(float)>&& progress = {})
Picks colors for the free entries of a palette, so the colors of an image look as close as they can.
colors are RGB colors as R | G << 8 | B << 16, alpha is ignored, each counts as many times as it's there. Entries for which locked is true keep their colors, and colors of the image are mapped to them too. Entry 0 is transparent, it's always locked. Colors are compared in OkLab — the boxes of a median cut give the first colors, which then move to the middles of the colors closest to them for a few rounds (k-means). With too many different colors for that to be quick, colors that differ only in the lowest 3 bits of each channel are taken together first. Returns the number of entries that were given a color. progress, if set, gets how far it is from 0 to 1 now and then, and stops it by returning false, -1 is returned then and the palette is left as it was.