Browse Source

Fix early exit bug in palette builder and change to far more conservative threshold

tznind 10 months ago
parent
commit
2378570015

+ 1 - 1
Terminal.Gui/Drawing/Quant/ColorQuantizer.cs

@@ -28,7 +28,7 @@ public class ColorQuantizer
     /// <summary>
     /// Gets or sets the algorithm used to build the <see cref="Palette"/>.
     /// </summary>
-    public IPaletteBuilder PaletteBuildingAlgorithm { get; set; } = new PopularityPaletteWithThreshold (new EuclideanColorDistance (),50) ;
+    public IPaletteBuilder PaletteBuildingAlgorithm { get; set; } = new PopularityPaletteWithThreshold (new EuclideanColorDistance (),5) ;
 
     public void BuildPalette (Color [,] pixels)
     {

+ 1 - 2
Terminal.Gui/Drawing/Quant/PopularityPaletteWithThreshold.cs

@@ -93,9 +93,8 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder
                 mergedHistogram [currentColor] = entry.Value;
             }
 
-
             // Early exit if we've reduced the colors to the maxColors limit
-            if (mergedHistogram.Count <= maxColors)
+            if (mergedHistogram.Count >= maxColors)
             {
                 return mergedHistogram;
             }