Browse Source

Make updates to the sixel image easier (e.g. changing algorithm)

tznind 10 months ago
parent
commit
36a8cba6e4
1 changed files with 20 additions and 7 deletions
  1. 20 7
      UICatalog/Scenarios/Images.cs

+ 20 - 7
UICatalog/Scenarios/Images.cs

@@ -60,6 +60,7 @@ public class Images : Scenario
     private RadioGroup _rgPaletteBuilder;
     private RadioGroup _rgPaletteBuilder;
     private RadioGroup _rgDistanceAlgorithm;
     private RadioGroup _rgDistanceAlgorithm;
     private NumericUpDown _popularityThreshold;
     private NumericUpDown _popularityThreshold;
+    private SixelToRender _sixelImage;
 
 
     public override void Main ()
     public override void Main ()
     {
     {
@@ -438,13 +439,25 @@ public class Images : Scenario
                                                _pxX.Value,
                                                _pxX.Value,
                                                _pxY.Value);
                                                _pxY.Value);
 
 
-        // TODO: Static way of doing this, suboptimal
-        Application.Sixel.Add (
-                               new()
-                               {
-                                   SixelData = _encodedSixelData,
-                                   ScreenPosition = _screenLocationForSixel
-                               });
+        if (_sixelImage == null)
+        {
+            _sixelImage = new ()
+            {
+                SixelData = _encodedSixelData,
+                ScreenPosition = _screenLocationForSixel
+            };
+
+            Application.Sixel.Add (_sixelImage);
+        }
+        else
+        {
+            _sixelImage.ScreenPosition = _screenLocationForSixel;
+            _sixelImage.SixelData = _encodedSixelData;
+        }
+
+        _sixelView.SetNeedsDisplay();
+
+
     }
     }
 
 
     private void SixelViewOnDrawContent (object sender, DrawEventArgs e)
     private void SixelViewOnDrawContent (object sender, DrawEventArgs e)