diff --git a/Terminal.Gui/Drawing/AssumeSupportDetector.cs b/Terminal.Gui/Drawing/AssumeSupportDetector.cs index c01b03f1c..46081714a 100644 --- a/Terminal.Gui/Drawing/AssumeSupportDetector.cs +++ b/Terminal.Gui/Drawing/AssumeSupportDetector.cs @@ -1,19 +1,19 @@ namespace Terminal.Gui; /// -/// Implementation of that assumes best -/// case scenario (full support including transparency with 10x20 resolution). +/// Implementation of that assumes best +/// case scenario (full support including transparency with 10x20 resolution). /// public class AssumeSupportDetector : ISixelSupportDetector { - /// + /// public SixelSupportResult Detect () { - return new SixelSupportResult + return new() { IsSupported = true, MaxPaletteColors = 256, - Resolution = new Size (10, 20), + Resolution = new (10, 20), SupportsTransparency = true }; } diff --git a/Terminal.Gui/Drawing/ISixelSupportDetector.cs b/Terminal.Gui/Drawing/ISixelSupportDetector.cs index 07ca43508..eb0bb9f12 100644 --- a/Terminal.Gui/Drawing/ISixelSupportDetector.cs +++ b/Terminal.Gui/Drawing/ISixelSupportDetector.cs @@ -1,14 +1,14 @@ namespace Terminal.Gui; /// -/// Interface for detecting sixel support. Either through -/// ansi requests to terminal or config file etc. +/// Interface for detecting sixel support. Either through +/// ansi requests to terminal or config file etc. /// public interface ISixelSupportDetector { /// - /// Gets the supported sixel state e.g. by sending Ansi escape sequences - /// or from a config file etc. + /// Gets the supported sixel state e.g. by sending Ansi escape sequences + /// or from a config file etc. /// /// Description of sixel support. public SixelSupportResult Detect (); diff --git a/Terminal.Gui/Drawing/Quant/ColorQuantizer.cs b/Terminal.Gui/Drawing/Quant/ColorQuantizer.cs index df362f4e0..5aa10c652 100644 --- a/Terminal.Gui/Drawing/Quant/ColorQuantizer.cs +++ b/Terminal.Gui/Drawing/Quant/ColorQuantizer.cs @@ -3,49 +3,49 @@ namespace Terminal.Gui; /// -/// Translates colors in an image into a Palette of up to colors (typically 256). +/// Translates colors in an image into a Palette of up to colors (typically 256). /// public class ColorQuantizer { /// - /// Gets the current colors in the palette based on the last call to - /// . + /// Gets the current colors in the palette based on the last call to + /// . /// public IReadOnlyCollection Palette { get; private set; } = new List (); /// - /// Gets or sets the maximum number of colors to put into the . - /// Defaults to 256 (the maximum for sixel images). + /// Gets or sets the maximum number of colors to put into the . + /// Defaults to 256 (the maximum for sixel images). /// public int MaxColors { get; set; } = 256; /// - /// Gets or sets the algorithm used to map novel colors into existing - /// palette colors (closest match). Defaults to + /// Gets or sets the algorithm used to map novel colors into existing + /// palette colors (closest match). Defaults to /// public IColorDistance DistanceAlgorithm { get; set; } = new EuclideanColorDistance (); /// - /// Gets or sets the algorithm used to build the . + /// Gets or sets the algorithm used to build the . /// - public IPaletteBuilder PaletteBuildingAlgorithm { get; set; } = new PopularityPaletteWithThreshold (new EuclideanColorDistance (),8) ; + public IPaletteBuilder PaletteBuildingAlgorithm { get; set; } = new PopularityPaletteWithThreshold (new EuclideanColorDistance (), 8); private readonly ConcurrentDictionary _nearestColorCache = new (); /// - /// Builds a of colors that most represent the colors used in image. - /// This is based on the currently configured . + /// Builds a of colors that most represent the colors used in image. + /// This is based on the currently configured . /// /// public void BuildPalette (Color [,] pixels) { - List allColors = new List (); + List allColors = new (); int width = pixels.GetLength (0); int height = pixels.GetLength (1); - for (int x = 0; x < width; x++) + for (var x = 0; x < width; x++) { - for (int y = 0; y < height; y++) + for (var y = 0; y < height; y++) { allColors.Add (pixels [x, y]); } @@ -57,14 +57,14 @@ public class ColorQuantizer public int GetNearestColor (Color toTranslate) { - if (_nearestColorCache.TryGetValue (toTranslate, out var cachedAnswer)) + if (_nearestColorCache.TryGetValue (toTranslate, out int cachedAnswer)) { return cachedAnswer; } // Simple nearest color matching based on DistanceAlgorithm - double minDistance = double.MaxValue; - int nearestIndex = 0; + var minDistance = double.MaxValue; + var nearestIndex = 0; for (var index = 0; index < Palette.Count; index++) { @@ -79,6 +79,7 @@ public class ColorQuantizer } _nearestColorCache.TryAdd (toTranslate, nearestIndex); + return nearestIndex; } -} \ No newline at end of file +} diff --git a/Terminal.Gui/Drawing/Quant/EuclideanColorDistance.cs b/Terminal.Gui/Drawing/Quant/EuclideanColorDistance.cs index e04a63972..935d59826 100644 --- a/Terminal.Gui/Drawing/Quant/EuclideanColorDistance.cs +++ b/Terminal.Gui/Drawing/Quant/EuclideanColorDistance.cs @@ -1,20 +1,21 @@ namespace Terminal.Gui; /// -/// -/// Calculates the distance between two colors using Euclidean distance in 3D RGB space. -/// This measures the straight-line distance between the two points representing the colors. -/// -/// -/// Euclidean distance in RGB space is calculated as: -/// -/// -/// √((R2 - R1)² + (G2 - G1)² + (B2 - B1)²) -/// -/// Values vary from 0 to ~441.67 linearly -/// -/// This distance metric is commonly used for comparing colors in RGB space, though -/// it doesn't account for perceptual differences in color. +/// +/// Calculates the distance between two colors using Euclidean distance in 3D RGB space. +/// This measures the straight-line distance between the two points representing the colors. +/// +/// +/// Euclidean distance in RGB space is calculated as: +/// +/// +/// √((R2 - R1)² + (G2 - G1)² + (B2 - B1)²) +/// +/// Values vary from 0 to ~441.67 linearly +/// +/// This distance metric is commonly used for comparing colors in RGB space, though +/// it doesn't account for perceptual differences in color. +/// /// public class EuclideanColorDistance : IColorDistance { @@ -24,6 +25,7 @@ public class EuclideanColorDistance : IColorDistance int rDiff = c1.R - c2.R; int gDiff = c1.G - c2.G; int bDiff = c1.B - c2.B; + return Math.Sqrt (rDiff * rDiff + gDiff * gDiff + bDiff * bDiff); } } diff --git a/Terminal.Gui/Drawing/Quant/IColorDistance.cs b/Terminal.Gui/Drawing/Quant/IColorDistance.cs index 892694344..fb8dc3aa2 100644 --- a/Terminal.Gui/Drawing/Quant/IColorDistance.cs +++ b/Terminal.Gui/Drawing/Quant/IColorDistance.cs @@ -1,15 +1,15 @@ namespace Terminal.Gui; /// -/// Interface for algorithms that compute the relative distance between pairs of colors. -/// This is used for color matching to a limited palette, such as in Sixel rendering. +/// Interface for algorithms that compute the relative distance between pairs of colors. +/// This is used for color matching to a limited palette, such as in Sixel rendering. /// public interface IColorDistance { /// - /// Computes a similarity metric between two instances. - /// A larger value indicates more dissimilar colors, while a smaller value indicates more similar colors. - /// The metric is internally consistent for the given algorithm. + /// Computes a similarity metric between two instances. + /// A larger value indicates more dissimilar colors, while a smaller value indicates more similar colors. + /// The metric is internally consistent for the given algorithm. /// /// The first color. /// The second color. diff --git a/Terminal.Gui/Drawing/Quant/IPaletteBuilder.cs b/Terminal.Gui/Drawing/Quant/IPaletteBuilder.cs index 999297cff..232842d99 100644 --- a/Terminal.Gui/Drawing/Quant/IPaletteBuilder.cs +++ b/Terminal.Gui/Drawing/Quant/IPaletteBuilder.cs @@ -1,16 +1,18 @@ namespace Terminal.Gui; /// -/// Builds a palette of a given size for a given set of input colors. +/// Builds a palette of a given size for a given set of input colors. /// public interface IPaletteBuilder { /// - /// Reduce the number of to (or less) - /// using an appropriate selection algorithm. + /// Reduce the number of to (or less) + /// using an appropriate selection algorithm. /// - /// Color of every pixel in the image. Contains duplication in order - /// to support algorithms that weigh how common a color is. + /// + /// Color of every pixel in the image. Contains duplication in order + /// to support algorithms that weigh how common a color is. + /// /// The maximum number of colours that should be represented. /// List BuildPalette (List colors, int maxColors); diff --git a/Terminal.Gui/Drawing/Quant/PopularityPaletteWithThreshold.cs b/Terminal.Gui/Drawing/Quant/PopularityPaletteWithThreshold.cs index 6941d0add..0a7e8a023 100644 --- a/Terminal.Gui/Drawing/Quant/PopularityPaletteWithThreshold.cs +++ b/Terminal.Gui/Drawing/Quant/PopularityPaletteWithThreshold.cs @@ -2,10 +2,10 @@ using Color = Terminal.Gui.Color; /// -/// Simple fast palette building algorithm which uses the frequency that a color is seen -/// to determine whether it will appear in the final palette. Includes a threshold where -/// by colors will be considered 'the same'. This reduces the chance of under represented -/// colors being missed completely. +/// Simple fast palette building algorithm which uses the frequency that a color is seen +/// to determine whether it will appear in the final palette. Includes a threshold where +/// by colors will be considered 'the same'. This reduces the chance of under represented +/// colors being missed completely. /// public class PopularityPaletteWithThreshold : IPaletteBuilder { @@ -13,7 +13,7 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder private readonly double _mergeThreshold; /// - /// Creates a new instance with the given color grouping parameters. + /// Creates a new instance with the given color grouping parameters. /// /// Determines which different colors can be considered the same. /// Threshold for merging two colors together. @@ -31,7 +31,7 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder } // Step 1: Build the histogram of colors (count occurrences) - Dictionary colorHistogram = new Dictionary (); + Dictionary colorHistogram = new (); foreach (Color color in colors) { @@ -64,14 +64,14 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder } /// - /// Merge colors in the histogram if they are within the threshold distance + /// Merge colors in the histogram if they are within the threshold distance /// /// /// /// private Dictionary MergeSimilarColors (Dictionary colorHistogram, int maxColors) { - Dictionary mergedHistogram = new Dictionary (); + Dictionary mergedHistogram = new (); foreach (KeyValuePair entry in colorHistogram) { diff --git a/Terminal.Gui/Drawing/SixelEncoder.cs b/Terminal.Gui/Drawing/SixelEncoder.cs index c05618e8c..70d9a44bc 100644 --- a/Terminal.Gui/Drawing/SixelEncoder.cs +++ b/Terminal.Gui/Drawing/SixelEncoder.cs @@ -4,12 +4,10 @@ // libsixel (C/C++) - https://github.com/saitoha/libsixel // Copyright (c) 2014-2016 Hayaki Saito @license MIT -using Terminal.Gui; - namespace Terminal.Gui; /// -/// Encodes a images into the sixel console image output format. +/// Encodes a images into the sixel console image output format. /// public class SixelEncoder { @@ -35,32 +33,29 @@ public class SixelEncoder */ - /// - /// Gets or sets the quantizer responsible for building a representative - /// limited color palette for images and for mapping novel colors in - /// images to their closest palette color + /// Gets or sets the quantizer responsible for building a representative + /// limited color palette for images and for mapping novel colors in + /// images to their closest palette color /// public ColorQuantizer Quantizer { get; set; } = new (); /// - /// Encode the given bitmap into sixel encoding + /// Encode the given bitmap into sixel encoding /// /// /// public string EncodeSixel (Color [,] pixels) { - const string start = "\u001bP"; // Start sixel sequence - - string defaultRatios = this.AnyHasAlphaOfZero(pixels) ? "0;1;0": "0;0;0"; // Defaults for aspect ratio and grid size + string defaultRatios = AnyHasAlphaOfZero (pixels) ? "0;1;0" : "0;0;0"; // Defaults for aspect ratio and grid size const string completeStartSequence = "q"; // Signals beginning of sixel image data const string noScaling = "\"1;1;"; // no scaling factors (1x1); string fillArea = GetFillArea (pixels); - string pallette = GetColorPalette (pixels ); + string pallette = GetColorPalette (pixels); string pixelData = WriteSixel (pixels); @@ -71,15 +66,14 @@ public class SixelEncoder private string WriteSixel (Color [,] pixels) { - - StringBuilder sb = new StringBuilder (); + var sb = new StringBuilder (); int height = pixels.GetLength (1); int width = pixels.GetLength (0); // Iterate over each 'row' of the image. Because each sixel write operation // outputs a screen area 6 pixels high (and 1+ across) we must process the image // 6 'y' units at once (1 band) - for (int y = 0; y < height; y += 6) + for (var y = 0; y < height; y += 6) { sb.Append (ProcessBand (pixels, y, Math.Min (6, height - y), width)); @@ -107,18 +101,18 @@ public class SixelEncoder Array.Fill (accu, (ushort)1); Array.Fill (slots, (short)-1); - var usedColorIdx = new List (); - var targets = new List> (); + List usedColorIdx = new List (); + List> targets = new List> (); // Process columns within the band - for (int x = 0; x < width; ++x) + for (var x = 0; x < width; ++x) { Array.Clear (code, 0, usedColorIdx.Count); // Process each row in the 6-pixel high band - for (int row = 0; row < bandHeight; ++row) + for (var row = 0; row < bandHeight; ++row) { - var color = pixels [x, startY + row]; + Color color = pixels [x, startY + row]; int colorIndex = Quantizer.GetNearestColor (color); @@ -129,12 +123,14 @@ public class SixelEncoder if (slots [colorIndex] == -1) { - targets.Add (new List ()); + targets.Add (new ()); + if (x > 0) { last [usedColorIdx.Count] = 0; accu [usedColorIdx.Count] = (ushort)x; } + slots [colorIndex] = (short)usedColorIdx.Count; usedColorIdx.Add (colorIndex); } @@ -143,7 +139,7 @@ public class SixelEncoder } // Handle transitions between columns - for (int j = 0; j < usedColorIdx.Count; ++j) + for (var j = 0; j < usedColorIdx.Count; ++j) { if (code [j] == last [j]) { @@ -155,6 +151,7 @@ public class SixelEncoder { targets [j].Add (CodeToSixel (last [j], accu [j])); } + last [j] = (sbyte)code [j]; accu [j] = 1; } @@ -162,7 +159,7 @@ public class SixelEncoder } // Process remaining data for this band - for (int j = 0; j < usedColorIdx.Count; ++j) + for (var j = 0; j < usedColorIdx.Count; ++j) { if (last [j] != 0) { @@ -172,7 +169,8 @@ public class SixelEncoder // Build the final output for this band var result = new StringBuilder (); - for (int j = 0; j < usedColorIdx.Count; ++j) + + for (var j = 0; j < usedColorIdx.Count; ++j) { result.Append ($"#{usedColorIdx [j]}{string.Join ("", targets [j])}$"); } @@ -182,7 +180,8 @@ public class SixelEncoder private static string CodeToSixel (int code, int repeat) { - char c = (char)(code + 63); + var c = (char)(code + 63); + if (repeat > 3) { return "!" + repeat + c; @@ -205,16 +204,18 @@ public class SixelEncoder { Quantizer.BuildPalette (pixels); - StringBuilder paletteSb = new StringBuilder (); + var paletteSb = new StringBuilder (); - for (int i = 0; i < Quantizer.Palette.Count; i++) + for (var i = 0; i < Quantizer.Palette.Count; i++) { - var color = Quantizer.Palette.ElementAt (i); - paletteSb.AppendFormat ("#{0};2;{1};{2};{3}", - i, - color.R * 100 / 255, - color.G * 100 / 255, - color.B * 100 / 255); + Color color = Quantizer.Palette.ElementAt (i); + + paletteSb.AppendFormat ( + "#{0};2;{1};{2};{3}", + i, + color.R * 100 / 255, + color.G * 100 / 255, + color.B * 100 / 255); } return paletteSb.ToString (); @@ -227,15 +228,16 @@ public class SixelEncoder return $"{widthInChars};{heightInChars}"; } + private bool AnyHasAlphaOfZero (Color [,] pixels) { int width = pixels.GetLength (0); int height = pixels.GetLength (1); // Loop through each pixel in the 2D array - for (int x = 0; x < width; x++) + for (var x = 0; x < width; x++) { - for (int y = 0; y < height; y++) + for (var y = 0; y < height; y++) { // Check if the alpha component (A) is 0 if (pixels [x, y].A == 0) @@ -244,6 +246,7 @@ public class SixelEncoder } } } + return false; // No pixel with A of 0 was found } -} \ No newline at end of file +} diff --git a/Terminal.Gui/Drawing/SixelSupportResult.cs b/Terminal.Gui/Drawing/SixelSupportResult.cs index 6bee9f320..bb8a61e0d 100644 --- a/Terminal.Gui/Drawing/SixelSupportResult.cs +++ b/Terminal.Gui/Drawing/SixelSupportResult.cs @@ -1,9 +1,9 @@ namespace Terminal.Gui; /// -/// Describes the discovered state of sixel support and ancillary information -/// e.g. . You can use any -/// to discover this information. +/// Describes the discovered state of sixel support and ancillary information +/// e.g. . You can use any +/// to discover this information. /// public class SixelSupportResult { diff --git a/Terminal.Gui/Drawing/SixelToRender.cs b/Terminal.Gui/Drawing/SixelToRender.cs index dc002c7ef..dedd399ef 100644 --- a/Terminal.Gui/Drawing/SixelToRender.cs +++ b/Terminal.Gui/Drawing/SixelToRender.cs @@ -1,19 +1,19 @@ namespace Terminal.Gui; /// -/// Describes a request to render a given at a given . -/// Requires that the terminal and both support sixel. +/// Describes a request to render a given at a given . +/// Requires that the terminal and both support sixel. /// public class SixelToRender { /// - /// gets or sets the encoded sixel data. Use to convert bitmaps - /// into encoded sixel data. + /// gets or sets the encoded sixel data. Use to convert bitmaps + /// into encoded sixel data. /// public string SixelData { get; set; } /// - /// gets or sets where to move the cursor to before outputting the . + /// gets or sets where to move the cursor to before outputting the . /// public Point ScreenPosition { get; set; } } diff --git a/UICatalog/Scenarios/Images.cs b/UICatalog/Scenarios/Images.cs index 1522822ba..13a552ee3 100644 --- a/UICatalog/Scenarios/Images.cs +++ b/UICatalog/Scenarios/Images.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Linq; using System.Text; @@ -70,7 +69,7 @@ public class Images : Scenario _sixelSupportResult = sixelSupportDetector.Detect (); Application.Init (); - _win = new() { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" }; + _win = new () { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" }; bool canTrueColor = Application.Driver?.SupportsTrueColor ?? false; @@ -79,7 +78,7 @@ public class Images : Scenario DisplayText = "Basic" }; - _tabSixel = new() + _tabSixel = new () { DisplayText = "Sixel" }; @@ -129,7 +128,7 @@ public class Images : Scenario var btnOpenImage = new Button { X = Pos.Right (cbUseTrueColor) + 2, Y = 0, Text = "Open Image" }; _win.Add (btnOpenImage); - _tabView = new() + _tabView = new () { Y = Pos.Bottom (btnOpenImage), Width = Dim.Fill (), Height = Dim.Fill () }; @@ -166,19 +165,18 @@ public class Images : Scenario if (!_sixelSupportResult.SupportsTransparency) { if (MessageBox.Query ( - "Transparency Not Supported", - "It looks like your terminal does not support transparent sixel backgrounds. Do you want to try anyway?", - "Yes", - "No") + "Transparency Not Supported", + "It looks like your terminal does not support transparent sixel backgrounds. Do you want to try anyway?", + "Yes", + "No") != 0) { return; } } - - _fire = new DoomFire (_win.Frame.Width * _pxX.Value, _win.Frame.Height * _pxY.Value); - _fireEncoder = new SixelEncoder (); + _fire = new (_win.Frame.Width * _pxX.Value, _win.Frame.Height * _pxY.Value); + _fireEncoder = new (); _fireEncoder.Quantizer.MaxColors = Math.Min (_fireEncoder.Quantizer.MaxColors, _sixelSupportResult.MaxPaletteColors); _fireEncoder.Quantizer.PaletteBuildingAlgorithm = new ConstPalette (_fire.Palette); @@ -294,14 +292,14 @@ public class Images : Scenario private void BuildSixelTab () { - _sixelSupported = new() + _sixelSupported = new () { Width = Dim.Fill (), Height = Dim.Fill (), CanFocus = true }; - _sixelNotSupported = new() + _sixelNotSupported = new () { Width = Dim.Fill (), Height = Dim.Fill (), @@ -318,7 +316,7 @@ public class Images : Scenario VerticalTextAlignment = Alignment.Center }); - _sixelView = new() + _sixelView = new () { Width = Dim.Percent (50), Height = Dim.Fill (), @@ -345,7 +343,6 @@ public class Images : Scenario btnStartFire.Accepting += BtnStartFireOnAccept; _sixelSupported.Add (btnStartFire); - var lblPxX = new Label { X = Pos.Right (_sixelView), @@ -353,7 +350,7 @@ public class Images : Scenario Text = "Pixels per Col:" }; - _pxX = new() + _pxX = new () { X = Pos.Right (lblPxX), Y = Pos.Bottom (btnStartFire) + 1, @@ -367,27 +364,27 @@ public class Images : Scenario Text = "Pixels per Row:" }; - _pxY = new() + _pxY = new () { X = Pos.Right (lblPxY), Y = Pos.Bottom (_pxX), Value = _sixelSupportResult.Resolution.Height }; - var l1 = new Label () + var l1 = new Label { Text = "Palette Building Algorithm", Width = Dim.Auto (), X = Pos.Right (_sixelView), - Y = Pos.Bottom (_pxY) + 1, + Y = Pos.Bottom (_pxY) + 1 }; - _rgPaletteBuilder = new RadioGroup + _rgPaletteBuilder = new() { RadioLabels = new [] { "Popularity", - "Median Cut", + "Median Cut" }, X = Pos.Right (_sixelView) + 2, Y = Pos.Bottom (l1), @@ -401,21 +398,22 @@ public class Images : Scenario Value = 8 }; - var lblPopThreshold = new Label () + var lblPopThreshold = new Label { Text = "(threshold)", X = Pos.Right (_popularityThreshold), - Y = Pos.Top (_popularityThreshold), + Y = Pos.Top (_popularityThreshold) }; - var l2 = new Label () + var l2 = new Label { Text = "Color Distance Algorithm", Width = Dim.Auto (), X = Pos.Right (_sixelView), - Y = Pos.Bottom (_rgPaletteBuilder) + 1, + Y = Pos.Bottom (_rgPaletteBuilder) + 1 }; - _rgDistanceAlgorithm = new RadioGroup () + + _rgDistanceAlgorithm = new() { RadioLabels = new [] { @@ -423,7 +421,7 @@ public class Images : Scenario "CIE76" }, X = Pos.Right (_sixelView) + 2, - Y = Pos.Bottom (l2), + Y = Pos.Bottom (l2) }; _sixelSupported.Add (lblPxX); @@ -441,7 +439,7 @@ public class Images : Scenario _sixelView.DrawContent += SixelViewOnDrawContent; } - IPaletteBuilder GetPaletteBuilder () + private IPaletteBuilder GetPaletteBuilder () { switch (_rgPaletteBuilder.SelectedItem) { @@ -451,7 +449,7 @@ public class Images : Scenario } } - IColorDistance GetDistanceAlgorithm () + private IColorDistance GetDistanceAlgorithm () { switch (_rgDistanceAlgorithm.SelectedItem) { @@ -466,6 +464,7 @@ public class Images : Scenario if (_imageView.FullResImage == null) { MessageBox.Query ("No Image Loaded", "You must first open an image. Use the 'Open Image' button above.", "Ok"); + return; } @@ -493,9 +492,7 @@ public class Images : Scenario _sixelImage.SixelData = _encodedSixelData; } - _sixelView.SetNeedsDisplay(); - - + _sixelView.SetNeedsDisplay (); } private void SixelViewOnDrawContent (object sender, DrawEventArgs e) diff --git a/UnitTests/Drawing/PopularityPaletteWithThresholdTests.cs b/UnitTests/Drawing/PopularityPaletteWithThresholdTests.cs index 7de04c652..9a89c70c0 100644 --- a/UnitTests/Drawing/PopularityPaletteWithThresholdTests.cs +++ b/UnitTests/Drawing/PopularityPaletteWithThresholdTests.cs @@ -25,7 +25,7 @@ public class PopularityPaletteWithThresholdTests { // Arrange var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50); - List colors = new() { new (255, 0), new (0, 255) }; + List colors = new () { new (255, 0), new (0, 255) }; // Act List result = paletteBuilder.BuildPalette (colors, 0); @@ -39,7 +39,7 @@ public class PopularityPaletteWithThresholdTests { // Arrange var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50); - List colors = new() { new (255, 0), new (255, 0) }; + List colors = new () { new (255, 0), new (255, 0) }; // Act List result = paletteBuilder.BuildPalette (colors, 256); @@ -55,7 +55,7 @@ public class PopularityPaletteWithThresholdTests // Arrange var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50); // Set merge threshold to 50 - List colors = new List + List colors = new() { new (255, 0), // Red new (250, 0), // Very close to Red @@ -78,7 +78,7 @@ public class PopularityPaletteWithThresholdTests // Arrange var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50); - List colors = new() + List colors = new () { new (255, 0), // Red new (0, 255) // Green @@ -99,7 +99,7 @@ public class PopularityPaletteWithThresholdTests // Arrange var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50); - List colors = new List + List colors = new() { new (255, 0), // Red new (254, 0), // Close to Red