Theory and Practice of Sprixels: Difference between revisions

No edit summary
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:


I've spent significant time over the past few weeks adding "sprixel" support to [[Notcurses]], culminating (thus far) in yesterday's [https://github.com/dankamongmen/notcurses/releases/tag/v2.2.4 2.2.4 release]. What's a sprixel? Numerous [https://github.com/dankamongmen/notcurses/blob/master/TERMINALS.md terminal emulators] support one or another "graphic protocol" by which bitmaps of arbitrary size can be written to the glyph-based viewing area. Showing that dynamic control of the font <b>is not</b> even approximately equivalent in power to such graphic protocols is left as an exercise for the reader (or you can scroll to the end).
I've spent significant time over the past few weeks adding "sprixel" support to [[Notcurses]], culminating (thus far) in yesterday's [https://github.com/dankamongmen/notcurses/releases/tag/v2.2.4 2.2.4 release]. What's a sprixel? Numerous [https://github.com/dankamongmen/notcurses/blob/master/TERMINALS.md terminal emulators] support one or another "graphic protocol" by which bitmaps of arbitrary size can be written to the glyph-based viewing area. Showing that dynamic control of the font <b>is not</b> even approximately equivalent in power to such graphic protocols is left as an exercise for the reader (or you can scroll to the end).
Sprite + Sixel → Sprixel.


==Sprixel flavors==
==Sprixel flavors==
Line 77: Line 79:


==Color quantization==
==Color quantization==
The Kitty protocol accepts arbitrary RGBA 32-bit words in the sRGB color space; our natural internal format is 24bpp RGB plus two bits of alpha, so that's great—our colorspaces match. Sixel is a palette-indexed format. Common sizes are 16-, 256-, and 1024-entry palettes (in XTerm, this is controlled with the <tt>numColorRegisters</tt> X resource). Palettes are independent unless the <tt>privateColorRegisters</tt> resource is explicitly set false). A color quantization step is thus necessary (note that this these quantizations can be performed in perfect parallelism when split across multiple frames/images, but not necessarily within a single frame). There are five essential color quantization algorithms:
The Kitty protocol accepts arbitrary RGBA 32-bit words in the sRGB color space; our natural internal format is 24bpp RGB plus two bits of alpha, so that's great—our colorspaces match. Sixel is a palette-indexed format. Common sizes are 16-, 256-, and 1024-entry palettes (in XTerm, this is controlled with the <tt>numColorRegisters</tt> X resource). Palettes are independent unless the <tt>privateColorRegisters</tt> resource is explicitly set false. A color quantization step is thus necessary (note that this these quantizations can be performed in perfect parallelism when split across multiple frames/images, but not necessarily within a single frame). There are five essential color quantization algorithms:


[[File:Penrosetiling.png|thumb|200px|right|These images throw libsixel for a loop; <tt>img2sixel</tt> chugs along, and then generates no output.]]
[[File:Penrosetiling.png|thumb|200px|right|These images throw libsixel for a loop; <tt>img2sixel</tt> chugs along, and then generates no output.]]