protected override Pixel QuantizatePixel(int x, int y) { // Get the color and add to the list Color color = image[y, x]; int colorIndex; if (listColor.Count < this.MaxColors) { if (!listColor.Contains(color)) { listColor.Add(color); } colorIndex = listColor.IndexOf(color); } else { // Create the labpalette if so if (nearestNeighbour == null) { LabColor[] labPalette = ColorConversion.ToLabPalette <Color>(listColor.ToArray()); nearestNeighbour = new ExhaustivePaletteSearch(); nearestNeighbour.Initialize(labPalette); } LabColor labNoTrans = ColorConversion.ToLabPalette <Color>(new Color[] { color })[0]; colorIndex = nearestNeighbour.Search(labNoTrans); } return(new Pixel((uint)colorIndex, (uint)color.Alpha, true)); }