about summary refs log tree commit diff stats
path: root/adapter/img/sixel.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-25 15:21:44 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-25 15:21:44 +0200
commite7c727c7fe399fb1b04af767495ec9d80183bc91 (patch)
tree6ea97381c2cc663ca51f5e0dd130a1ad5d9c88c2 /adapter/img/sixel.nim
parent052697585d5d31691229693a9d4ed03b6dfb2337 (diff)
downloadchawan-e7c727c7fe399fb1b04af767495ec9d80183bc91.tar.gz
term: prevent negative line damage, fix off by one
Diffstat (limited to 'adapter/img/sixel.nim')
-rw-r--r--adapter/img/sixel.nim8
1 files changed, 6 insertions, 2 deletions
diff --git a/adapter/img/sixel.nim b/adapter/img/sixel.nim
index f813ae77..676197bf 100644
--- a/adapter/img/sixel.nim
+++ b/adapter/img/sixel.nim
@@ -8,7 +8,11 @@
 # follows:
 #
 # * DCS q set-raster-attributes is omitted.
-# * 32-bit binary number in header indicates length of following palette.
+# * 32-bit binary number in header indicates the end of the following
+#   palette. (Note: this includes this 32-bit number's and the following 8-bit
+#   number's length as well.)
+# * This is followed by an 8-bit number indicating whether the image includes
+#   transparent pixels.
 # * A lookup table is appended to the file end, which includes (height + 5) / 6
 #   32-bit binary numbers indicating the start index of every 6th row.
 #
@@ -384,7 +388,7 @@ proc encode(img: openArray[RGBAColorBE]; width, height, offx, offy, cropw: int;
   let nodes = root.flatten(outs, palette)
   if halfdump:
     # prepend prelude size
-    let L = outs.len - 4 - preludeLenPos # subtract length field
+    let L = outs.len - preludeLenPos
     outs.setU32BE(uint32(L), preludeLenPos)
   let os = newPosixStream(STDOUT_FILENO)
   let L = width * height