diff options
author | bptato <nincsnevem662@gmail.com> | 2024-08-28 19:32:03 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-08-28 19:32:03 +0200 |
commit | 8c8c19f7cb49ff5cb73ea12317e0ff54ecb6c53a (patch) | |
tree | a330d30f72fc0e6695b1034e12170108e419a619 /adapter/img/sixel.nim | |
parent | a4d44bb0d60e18b4c7a44e89d4493734cefea297 (diff) | |
download | chawan-8c8c19f7cb49ff5cb73ea12317e0ff54ecb6c53a.tar.gz |
sixel, term: fix off-by-1's in cropping
& clean up outputSixelImage in general
Diffstat (limited to 'adapter/img/sixel.nim')
-rw-r--r-- | adapter/img/sixel.nim | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/adapter/img/sixel.nim b/adapter/img/sixel.nim index 7f4514d9..e06b85e7 100644 --- a/adapter/img/sixel.nim +++ b/adapter/img/sixel.nim @@ -302,10 +302,13 @@ proc encode(s: string; width, height, offx, offy, cropw: int; halfdump: bool; bands[k].data[j] = bands[k].data[j] or mask n += W outs.setLen(0) - for i in 0 ..< bands.high: + var i = 0 + while true: outs &= bands[i].compressSixel() + inc i + if i >= bands.len: + break outs &= '$' - outs &= bands[^1].compressSixel() if n >= H: outs &= ST else: @@ -314,6 +317,7 @@ proc encode(s: string; width, height, offx, offy, cropw: int; halfdump: bool; stdout.write(outs) if halfdump: ymap.putU32BE(uint32(totalLen)) + ymap.putU32BE(uint32(ymap.len)) stdout.write(ymap) proc parseDimensions(s: string): (int, int) = |