mirror of
https://github.com/tmux/tmux.git
synced 2025-09-07 10:27:00 +00:00
Add helpers to scroll image up and a flag to copy the colours.
This commit is contained in:
16
sixel.c
16
sixel.c
@ -350,11 +350,11 @@ sixel_size_in_cells(struct sixel_image *si, u_int *x, u_int *y)
|
||||
|
||||
struct sixel_image *
|
||||
sixel_scale(struct sixel_image *si, u_int xpixel, u_int ypixel, u_int ox,
|
||||
u_int oy, u_int sx, u_int sy)
|
||||
u_int oy, u_int sx, u_int sy, int colours)
|
||||
{
|
||||
struct sixel_image *new;
|
||||
u_int cx, cy, pox, poy, psx, psy, tsx, tsy, px, py;
|
||||
u_int x, y;
|
||||
u_int x, y, i;
|
||||
|
||||
/*
|
||||
* We want to get the section of the image at ox,oy in image cells and
|
||||
@ -372,6 +372,11 @@ sixel_scale(struct sixel_image *si, u_int xpixel, u_int ypixel, u_int ox,
|
||||
if (oy + sy >= cy)
|
||||
sy = cy - oy;
|
||||
|
||||
if (xpixel == 0)
|
||||
xpixel = si->xpixel;
|
||||
if (ypixel == 0)
|
||||
ypixel = si->ypixel;
|
||||
|
||||
pox = ox * si->xpixel;
|
||||
poy = oy * si->ypixel;
|
||||
psx = sx * si->xpixel;
|
||||
@ -391,6 +396,13 @@ sixel_scale(struct sixel_image *si, u_int xpixel, u_int ypixel, u_int ox,
|
||||
sixel_set_pixel(new, x, y, sixel_get_pixel(si, px, py));
|
||||
}
|
||||
}
|
||||
|
||||
if (colours) {
|
||||
new->colours = xmalloc(si->ncolours * sizeof *new->colours);
|
||||
for (i = 0; i < si->ncolours; i++)
|
||||
new->colours[i] = si->colours[i];
|
||||
new->ncolours = si->ncolours;
|
||||
}
|
||||
return (new);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user