diff --git a/src/lib/internal.h b/src/lib/internal.h index 8001bbc9b..ce1552887 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -415,15 +415,17 @@ typedef struct notcurses { // cell vs pixel-specific arguments typedef union { struct { - int placey; // placement within ncplane - int placex; int blendcolors; // use CELL_ALPHA_BLEND + int placey; // placement within ncplane + int placex; } cell; // for cells struct { int celldimx; // horizontal pixels per cell int celldimy; // vertical pixels per cell int colorregs; // number of color registers int sprixelid; // unqie 24-bit id into sprixel cache + int placey; // placement within ncplane + int placex; } pixel; // for pixels } blitterargs; @@ -702,8 +704,8 @@ plane_debug(const ncplane* n, bool details){ void sprixel_free(sprixel* s); void sprixel_hide(sprixel* s); // dimy and dimx are cell geometry, not pixel -sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int sprixelid, - int dimy, int dimx, int pixy, int pixx); +sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int placex, + int sprixelid, int dimy, int dimx, int pixy, int pixx); API int sprite_wipe_cell(const notcurses* nc, sprixel* s, int y, int x); int sprite_kitty_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s); int sprite_sixel_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s); @@ -1100,15 +1102,15 @@ egc_rtl(const char* egc, int* bytes){ // a reference to the context-wide sprixel cache. this ought be an entirely // new, purpose-specific plane. static inline int -plane_blit_sixel(ncplane* n, const char* s, int bytes, int leny, int lenx, - int sprixelid, int dimy, int dimx){ - sprixel* spx = sprixel_create(n, s, bytes, sprixelid, leny, lenx, dimy, dimx); +plane_blit_sixel(ncplane* n, const char* s, int bytes, int placey, int placex, + int leny, int lenx, int sprixelid, int dimy, int dimx){ + sprixel* spx = sprixel_create(n, s, bytes, placey, placex, sprixelid, leny, lenx, dimy, dimx); if(spx == NULL){ return -1; } uint32_t gcluster = htole(0x02000000ul) + htole(spx->id); - for(int y = 0 ; y < leny && y < ncplane_dim_y(n) ; ++y){ - for(int x = 0 ; x < lenx && x < ncplane_dim_x(n) ; ++x){ + for(int y = placey ; y < placey + leny && y < ncplane_dim_y(n) ; ++y){ + for(int x = placex ; x < placex + lenx && x < ncplane_dim_x(n) ; ++x){ nccell* c = ncplane_cell_ref_yx(n, y, x); memcpy(&c->gcluster, &gcluster, sizeof(gcluster)); c->width = lenx; diff --git a/src/lib/kitty.c b/src/lib/kitty.c index e0fe9d16d..76c54af32 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -255,7 +255,8 @@ int kitty_blit_inner(ncplane* nc, int linesize, int leny, int lenx, free(buf); return -1; } - if(plane_blit_sixel(nc, buf, size, rows, cols, bargs->pixel.sprixelid, leny, lenx) < 0){ + if(plane_blit_sixel(nc, buf, size, bargs->pixel.placey, bargs->pixel.placex, + rows, cols, bargs->pixel.sprixelid, leny, lenx) < 0){ free(buf); return -1; } diff --git a/src/lib/render.c b/src/lib/render.c index 5114f9d56..6c72cfc62 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -971,6 +971,8 @@ rasterize_sprixels(notcurses* nc, const ncpile* p, FILE* out){ if(s->invalidated == SPRIXEL_INVALIDATED){ int y, x; ncplane_yx(s->n, &y, &x); + y += s->y; + x += s->x; //fprintf(stderr, "DRAWING BITMAP AT %d/%d\n", y, x); if(goto_location(nc, out, y + nc->stdplane->absy, x + nc->stdplane->absx)){ return -1; diff --git a/src/lib/sixel.c b/src/lib/sixel.c index 54d2cb5ef..6030fd3fb 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -81,9 +81,9 @@ fprintf(stderr, "TARGET AREA: [ %dx%d -> %dx%d ] of %dx%d\n", top, left, bottom rle = 0; } if(column >= left && column < right){ // zorch it -fprintf(stderr, "STARTED WITH %d %c\n", *c, *c); +//fprintf(stderr, "STARTED WITH %d %c\n", *c, *c); *c = ((*c - 63) & mask) + 63; -fprintf(stderr, "CHANGED TO %d %c\n", *c, *c); +//fprintf(stderr, "CHANGED TO %d %c\n", *c, *c); } ++column; } @@ -504,7 +504,8 @@ int sixel_blit_inner(ncplane* nc, int leny, int lenx, sixeltable* stab, } unsigned cols = lenx / bargs->pixel.celldimx + !!(lenx % bargs->pixel.celldimx); unsigned rows = leny / bargs->pixel.celldimy + !!(leny % bargs->pixel.celldimy); - if(plane_blit_sixel(nc, buf, size, rows, cols, bargs->pixel.sprixelid, leny, lenx) < 0){ + if(plane_blit_sixel(nc, buf, size, bargs->pixel.placey, bargs->pixel.placex, + rows, cols, bargs->pixel.sprixelid, leny, lenx) < 0){ free(buf); return -1; } diff --git a/src/lib/sprite.c b/src/lib/sprite.c index 7f1f2de31..34c73930c 100644 --- a/src/lib/sprite.c +++ b/src/lib/sprite.c @@ -17,8 +17,8 @@ void sprixel_hide(sprixel* s){ } // y and x are the cell geometry, not the pixel geometry -sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int sprixelid, - int dimy, int dimx, int pixy, int pixx){ +sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int placex, + int sprixelid, int dimy, int dimx, int pixy, int pixx){ sprixel* ret = malloc(sizeof(sprixel)); if(ret){ if((ret->glyph = memdup(s, bytes + 1)) == NULL){ @@ -40,6 +40,8 @@ sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int sprixelid, ret->dimx = dimx; ret->pixx = pixx; ret->pixy = pixy; + ret->y = placey; + ret->x = placex; if(ncplane_pile(n)){ notcurses* nc = ncplane_notcurses(n); ret->next = nc->sprixelcache; diff --git a/src/lib/visual.c b/src/lib/visual.c index 8ea2eeb83..093278f28 100644 --- a/src/lib/visual.c +++ b/src/lib/visual.c @@ -530,6 +530,8 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits bargs.pixel.celldimy = nc->tcache.cellpixy; bargs.pixel.colorregs = nc->tcache.color_registers; bargs.pixel.sprixelid = nc->tcache.sprixelnonce++; + bargs.pixel.placey = placey; + bargs.pixel.placex = placex; if(ncvisual_blit(ncv, disprows, dispcols, n, bset, begy, begx, disprows, dispcols, &bargs)){ ncplane_destroy(n);