public PaletteFrameQuantizer(Configuration configuration, QuantizerOptions options, ReadOnlyMemory <TPixel> colors) { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(options, nameof(options)); this.Configuration = configuration; this.Options = options; this.palette = colors; this.pixelMap = new EuclideanPixelMap <TPixel>(colors); }
public PaletteQuantizer( Configuration configuration, QuantizerOptions options, EuclideanPixelMap <TPixel> pixelMap) { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(options, nameof(options)); this.Configuration = configuration; this.Options = options; this.pixelMap = pixelMap; }
public OctreeFrameQuantizer(Configuration configuration, QuantizerOptions options) { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(options, nameof(options)); this.Configuration = configuration; this.Options = options; this.colors = this.Options.MaxColors; this.octree = new Octree(ImageMaths.GetBitsNeededForColorDepth(this.colors).Clamp(1, 8)); this.pixelMap = default; this.isDithering = !(this.Options.Dither is null); }
public OctreeQuantizer(Configuration configuration, QuantizerOptions options) { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(options, nameof(options)); this.Configuration = configuration; this.Options = options; this.maxColors = this.Options.MaxColors; this.octree = new Octree(Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8)); this.paletteOwner = configuration.MemoryAllocator.Allocate <TPixel>(this.maxColors, AllocationOptions.Clean); this.palette = default; this.pixelMap = default; this.isDithering = !(this.Options.Dither is null); this.isDisposed = false; }
public WuFrameQuantizer(Configuration configuration, QuantizerOptions options) { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(options, nameof(options)); this.Configuration = configuration; this.Options = options; this.memoryAllocator = this.Configuration.MemoryAllocator; this.moments = this.memoryAllocator.Allocate <Moment>(TableLength, AllocationOptions.Clean); this.tag = this.memoryAllocator.Allocate <byte>(TableLength, AllocationOptions.Clean); this.colors = this.Options.MaxColors; this.colorCube = new Box[this.colors]; this.isDisposed = false; this.pixelMap = default; this.isDithering = this.isDithering = !(this.Options.Dither is null); }
/// <inheritdoc /> public IQuantizer <TPixel> CreatePixelSpecificQuantizer <TPixel>(Configuration configuration, QuantizerOptions options) where TPixel : unmanaged, IPixel <TPixel> { Guard.NotNull(options, nameof(options)); // The palette quantizer can reuse the same pixel map across multiple frames // since the palette is unchanging. This allows a reduction of memory usage across // multi frame gifs using a global palette. int length = Math.Min(this.colorPalette.Length, options.MaxColors); var palette = new TPixel[length]; Color.ToPixel(configuration, this.colorPalette.Span, palette.AsSpan()); var pixelMap = new EuclideanPixelMap <TPixel>(configuration, palette); return(new PaletteQuantizer <TPixel>(configuration, options, pixelMap)); }
/// <inheritdoc/> public void Dispose() { this.pixelMap?.Dispose(); this.pixelMap = null; }
/// <inheritdoc/> public bool Equals(EuclideanPixelMap <TPixel> other) => this.Palette.Equals(other.Palette);