mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Fix early exit bug in palette builder and change to far more conservative threshold
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user