/// <inheritdoc/> public override QuantizedFrame <TPixel> Quantize(ImageFrame <TPixel> image, int maxColors) { Guard.NotNull(image, nameof(image)); this.colors = maxColors.Clamp(1, 255); this.palette = null; this.colorMap.Clear(); MemoryManager memoryManager = image.MemoryManager; try { this.vwt = memoryManager.AllocateClean <long>(TableLength); this.vmr = memoryManager.AllocateClean <long>(TableLength); this.vmg = memoryManager.AllocateClean <long>(TableLength); this.vmb = memoryManager.AllocateClean <long>(TableLength); this.vma = memoryManager.AllocateClean <long>(TableLength); this.m2 = memoryManager.AllocateClean <float>(TableLength); this.tag = memoryManager.AllocateClean <byte>(TableLength); return(base.Quantize(image, this.colors)); } finally { this.vwt.Dispose(); this.vmr.Dispose(); this.vmg.Dispose(); this.vmb.Dispose(); this.vma.Dispose(); this.m2.Dispose(); this.tag.Dispose(); } }
/// <inheritdoc/> public override QuantizedFrame <TPixel> QuantizeFrame(ImageFrame <TPixel> image) { Guard.NotNull(image, nameof(image)); MemoryManager memoryManager = image.MemoryManager; try { this.vwt = memoryManager.AllocateClean <long>(TableLength); this.vmr = memoryManager.AllocateClean <long>(TableLength); this.vmg = memoryManager.AllocateClean <long>(TableLength); this.vmb = memoryManager.AllocateClean <long>(TableLength); this.vma = memoryManager.AllocateClean <long>(TableLength); this.m2 = memoryManager.AllocateClean <float>(TableLength); this.tag = memoryManager.AllocateClean <byte>(TableLength); return(base.QuantizeFrame(image)); } finally { this.vwt?.Dispose(); this.vmr?.Dispose(); this.vmg?.Dispose(); this.vmb?.Dispose(); this.vma?.Dispose(); this.m2?.Dispose(); this.tag?.Dispose(); } }