public QuantizeImageSettings(IColorQuantizer quantizer) { Quantizer = quantizer ?? throw new ArgumentNullException(nameof(quantizer)); Ditherer = null; ColorCache = new EuclideanDistanceColorCache(); ColorModel = ColorModel.RGB; ColorCount = 256; ParallelCount = 8; }
private ColorPalette GetColours(Image sourceImage, PictureBox picture) { IColorQuantizer activeQuantizer = new DistinctSelectionQuantizer(); IColorCache activeColorCache = new EuclideanDistanceColorCache(); ((BaseColorCacheQuantizer)activeQuantizer).ChangeCacheProvider(activeColorCache); ((BaseColorCache)activeColorCache).ChangeColorModel(ColorModel.RedGreenBlue); Int32 parallelTaskCount = 8; TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); Image targetImage = ImageBuffer.QuantizeImage(sourceImage, activeQuantizer, null, 2, parallelTaskCount); picture.Image = targetImage; return(targetImage.Palette); }
/// <summary> /// Creates a new instance of <see cref="QuantizationSettings"/>. /// </summary> /// <param name="quantizer">The quantizer to use.</param> /// <param name="width">The width of the image.</param> /// <param name="height">The height of the image.</param> public QuantizationSettings(IColorQuantizer quantizer, int width, int height) { if (width <= 0) { throw new ArgumentOutOfRangeException(nameof(width)); } if (height <= 0) { throw new ArgumentOutOfRangeException(nameof(height)); } Quantizer = quantizer ?? throw new ArgumentNullException(nameof(quantizer)); Width = width; Height = height; Ditherer = null; ColorCache = new EuclideanDistanceColorCache(); ColorModel = ColorModel.RGB; ColorCount = 256; ParallelCount = 8; }