Browse Source

Use round to nearest whole number when calculating sixel resolution from window size/chars

tznind 10 months ago
parent
commit
4073ef305c
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Terminal.Gui/Drawing/SixelSupportDetector.cs

+ 2 - 2
Terminal.Gui/Drawing/SixelSupportDetector.cs

@@ -71,8 +71,8 @@ public class SixelSupportDetector
                             charWidth != 0 && charHeight != 0) // Avoid divide by zero
                         {
                             // Calculate the character cell size in pixels
-                            var cellWidth = pixelWidth / charWidth;
-                            var cellHeight = pixelHeight / charHeight;
+                            var cellWidth = (int)Math.Round ((double)pixelWidth / charWidth);
+                            var cellHeight = (int)Math.Round ((double)pixelHeight / charHeight);
 
                             // Set the resolution based on the character cell size
                             result.Resolution = new Size (cellWidth, cellHeight);