about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-12 22:37:14 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-12 23:09:16 +0200
commita50651c944939b783ea186ef5b109f91368373d0 (patch)
treeb573b394a7662b6598226067c424ffdbceaf736d /src
parent5fc57d88ac534ca63925444f2d1f7ced1c02aa3a (diff)
downloadchawan-a50651c944939b783ea186ef5b109f91368373d0.tar.gz
sixel: do not reserve palette entry for transparency
Turns out this isn't actually needed. Which makes sense, as transparency
doesn't have a color register at all - it's just the default state of
pixels.

Also, skip octree-based quantization with palette <= 2; unsurprisingly,
monochrome gives much better results.
Diffstat (limited to 'src')
-rw-r--r--src/local/term.nim8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/local/term.nim b/src/local/term.nim
index 3ab72d80..8d7cc353 100644
--- a/src/local/term.nim
+++ b/src/local/term.nim
@@ -620,7 +620,7 @@ proc applyConfig(term: Terminal) =
     term.imageMode = term.config.display.image_mode.get
   if term.imageMode == imSixel and term.config.display.sixel_colors.isSome:
     let n = term.config.display.sixel_colors.get
-    term.sixelRegisterNum = clamp(n, 3, 65535)
+    term.sixelRegisterNum = clamp(n, 2, 65535)
   if term.isatty():
     if term.config.display.alt_screen.isSome:
       term.smcup = term.config.display.alt_screen.get
@@ -1210,12 +1210,12 @@ proc detectTermAttributes(term: Terminal; windowOnly: bool): TermStartResult =
           term.imageMode = imKitty
       if term.imageMode == imSixel: # adjust after windowChange
         if r.registers != 0:
-          # I need at least 3 registers (1 for transparency), and can't do
-          # anything with more than 101 ^ 3.
+          # I need at least 2 registers, and can't do anything with more
+          # than 101 ^ 3.
           # In practice, terminals I've seen have between 256 - 65535; for now,
           # I'll stick with 65535 as the upper limit, because I have no way
           # to test if encoding time explodes with more or something.
-          term.sixelRegisterNum = clamp(r.registers, 3, 65535)
+          term.sixelRegisterNum = clamp(r.registers, 2, 65535)
         if term.sixelRegisterNum == 0:
           # assume 256 - tell me if you have more.
           term.sixelRegisterNum = 256