[sixel]: set P2=1

This indicates that empty pixels should "remain at their current
color". I.e. it makes them transparent.

This is in contrast to P2=0|2, where empty pixels are filled with the
"current background color" (which is either sixel color register #0,
or the current ANSI background color, depending on terminal and its
sixel implementation).

Note that due to what is most likely a bug, XTerm will behave as if
P2=1 if P2 is either left unset, or explicitly set to 0 or 2, as long
as we do *not* emit a "Set Raster Attributes" command.
This commit is contained in:
Daniel Eklöf 2021-04-11 00:35:55 +02:00 committed by Nick Black
parent 9c7fa38187
commit 8b7fa78be1

View File

@ -317,7 +317,8 @@ write_rle(int* printed, int color, FILE* fp, int seenrle, unsigned char crle){
// Closes |fp| on all paths.
static int
write_sixel_data(FILE* fp, int leny, int lenx, const sixeltable* stab, int* parse_start){
*parse_start = fprintf(fp, "\ePq");
// Set P2=1, turning empty pixels transparent
*parse_start = fprintf(fp, "\eP0;1;0q");
// Set Raster Attributes - pan/pad=1 (pixel aspect ratio), Ph=lenx, Pv=leny
// using Ph/Pv causes a background to be drawn using color register 0 for all
// unspecified pixels, which we do not want.