Make sixel images grid resident - #5463
Conversation
Replace screen-coordinate image placements with immutable pixel images referenced by ordinary grid cells. Draw visible marker runs through the redraw scene using per-client sixel or text backends so images follow history, copy mode, clipping and overwrites.
Use the DEC hue origin and channel order, and round percentage and HLS conversions to the nearest byte value.
Retain the padded canonical pixel canvas separately from the image content. Scale only the populated portion of partial edge cells so an image keeps its exact raster size on the originating terminal while retaining its cell footprint.
Build an adaptive 256-colour palette with median cut instead of using a fixed colour cube. Apply Floyd-Steinberg error diffusion while mapping pixels to reduce banding and preserve image detail.
|
Here are a few quick comments:
|
|
|
…77. Kitty images now use the adaptive 256-colour median-cut palette with direct nearest-colour mapping.
…n the image, the image was overflowing lines and banding.
…xel.c:1077. Kitty images now use the adaptive 256-colour median-cut palette with direct nearest-colour mapping." This reverts commit 00ffe74.
I've done this. There are 3 branches now: |
I looked into this. Unfortunately not really. Kitty uses a 24-bit image-id so internally it becomes 32-bits. Kitty also handles things like the x and y and other things as uint so reducing the x and y to 16 bits would introduce a lot more checking and could potentially cause an issue with large images. The tradeoff to save a few bytes here is not going to be worth it.
I would not add a union there. Although graphical backends replace the character with a space, the other fields still matter:
In particular, an image flag is not immutable: later grid operations can clear or replace it while retaining the rest of A separate image-specific extended-cell representation could save memory, but it would require explicit conversion logic
I've propagated the checks using this in the 4902-image-support branch to the foundation sixel branch now.
Done. image_sample, image_cell, image, and image_rectangle are now private to image.c; tmux.h contains only forward declarations and the accessor interface. The SIXEL, Kitty, and fallback renderers now use those accessors rather than reaching into the image structures directly.
fixed.
Done.
should be fixed now.
Done. |
|
An extra 12 bytes is adding almost a third to the size of I think we should ignore images more than 64k wide or 64k high and reduce the X and Y to Or, if you could store X and Y as cells instead of pixels you could have the image as 64k cells wide or high, which would be impossible to reach. For the ID, it is silly to store the same 32 bit ID in every cell which references the image and waste four bytes in cells which have no image. Nobody will have 4 billion images. So I would either:
|
|
You don't need to store the data in the same format in |
This reverts commit 3e3567b.
…ne later overwritten by text. On a SIXEL terminal, damaged cells are omitted from image output; on Kitty they remain ordinary positional placements.
…d first in the cell.
Replace screen-coordinate image placements with immutable pixel images referenced by ordinary grid cells. Draw visible marker runs through the redraw scene using per-client sixel or text backends so images follow history, copy mode, clipping and overwrites.