/// <summary> /// Initializes a new instance of the <see cref="DistinctColorInfo"/> struct. /// </summary> public DistinctColorInfo(TextureBitmap.Color color) { Color = color.ToARGB(); Count = 1; Hue = Convert.ToInt32(color.GetHue() * Factor); Saturation = Convert.ToInt32(color.GetSaturation() * Factor); Brightness = Convert.ToInt32(color.GetBrightness() * Factor); }
/// <summary> /// See <see cref="BaseColorQuantizer.AddColor"/> for more details. /// </summary> protected override void OnAddColor(TextureBitmap.Color color, Int32 key, Int32 x, Int32 y) { Int32 indexRed = (color.R >> 3) + 1; Int32 indexGreen = (color.G >> 3) + 1; Int32 indexBlue = (color.B >> 3) + 1; int index = indexRed + indexGreen * SideSize + indexBlue * SideSize * SideSize; weights[index]++; momentsRed[index] += color.R; momentsGreen[index] += color.G; momentsBlue[index] += color.B; moments[index] += table[color.R] + table[color.G] + table[color.B]; quantizedPixels[pixelIndex] = (indexRed << 10) + (indexRed << 6) + indexRed + (indexGreen << 5) + indexGreen + indexBlue; pixels[pixelIndex] = color.ToARGB(); pixelIndex++; }