public void CreatePalette(IEnumerable <Color> colors) { // Step 1: Build a 3-dimensional histogram of all colors and calculate their moments var histogram = new Wu3DHistogram(colors.ToArray(), _indexBits, _indexAlphaBits, _indexCount, _indexAlphaCount); // Step 2: Create color cube var cube = WuColorCube.Create(histogram, _colorCount); // Step 3: Create palette from color cube _palette = CreatePalette(cube).ToList(); }
public WuColorQuantizer(int indexBits, int indexAlphaBits, int colorCount) { _colorCache = new WuColorCache(indexBits, indexAlphaBits); _histogram = new Wu3DHistogram(indexBits, indexAlphaBits, (1 << indexBits) + 1, (1 << indexAlphaBits) + 1); var tableLength = _histogram.IndexCount * _histogram.IndexCount * _histogram.IndexCount * _histogram.IndexAlphaCount; _colorCache.Tag = new byte[tableLength]; _colorCount = colorCount; }