#57 add raster information
authorKevin Lamonte <kevin.lamonte@gmail.com>
Fri, 30 Aug 2019 22:59:30 +0000 (17:59 -0500)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Fri, 30 Aug 2019 22:59:30 +0000 (17:59 -0500)
src/jexer/backend/ECMA48Terminal.java

index 9884835591adba9cfa57530cca3759ee8fb6404e..75c4ce407e4b05e9bcade8af846da8b9bbb6f426 100644 (file)
@@ -3083,6 +3083,10 @@ public class ECMA48Terminal extends LogicalScreen
         }
         image = palette.ditherImage(image);
 
+        // Collect the raster information
+        int rasterHeight = 0;
+        int rasterWidth = image.getWidth();
+
         // Emit the palette, but only for the colors actually used by these
         // cells.
         boolean [] usedColors = new boolean[sixelPaletteSize];
@@ -3159,6 +3163,9 @@ public class ECMA48Terminal extends LogicalScreen
                                 data += 32;
                                 break;
                             }
+                            if ((currentRow + j + 1) > rasterHeight) {
+                                rasterHeight = currentRow + j + 1;
+                            }
                         }
                     }
                     assert (data >= 0);
@@ -3198,6 +3205,9 @@ public class ECMA48Terminal extends LogicalScreen
         // Kill the very last "-", because it is unnecessary.
         sb.deleteCharAt(sb.length() - 1);
 
+        // Add the raster information
+        sb.insert(0, String.format("\"1;1;%d;%d", rasterWidth, rasterHeight));
+
         if (saveInCache) {
             // This row is OK to save into the cache.
             sixelCache.put(cells, sb.toString());