tria_blit(): interpret missing row as transparent #566

pull/587/head
nick black 4 years ago
parent f63325db60
commit 4446bbdf06
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -19,11 +19,11 @@ tria_blit(ncplane* nc, int placey, int placex, int linesize, const void* data,
const int rpos = bgr ? 2 : 0;
const int bpos = bgr ? 0 : 2;
int dimy, dimx, x, y;
int visy = begy;
int total = 0; // number of cells written
ncplane_dim_yx(nc, &dimy, &dimx);
// FIXME not going to necessarily be safe on all architectures hrmmm
const unsigned char* dat = data;
int visy = begy;
for(y = placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 2){
if(ncplane_cursor_move_yx(nc, y, placex)){
return -1;
@ -32,6 +32,9 @@ tria_blit(ncplane* nc, int placey, int placex, int linesize, const void* data,
for(x = placex ; visx < (begx + lenx) && x < dimx ; ++x, ++visx){
const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * bpp / CHAR_BIT);
const unsigned char* rgbbase_down = dat + (linesize * (visy + 1)) + (visx * bpp / CHAR_BIT);
if(visy == begy + leny - 1){
rgbbase_down = (const unsigned char*)"\x00\x00\x00\x00";
}
//fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]);
cell* c = ncplane_cell_ref_yx(nc, y, x);
// use the default for the background, as that's the only way it's

@ -210,25 +210,18 @@ ncvisual* ncvisual_from_rgba(notcurses* nc, const void* rgba, int rows,
ncv->ncobj = nc;
ncv->dstwidth = cols;
ncv->dstheight = rows;
if(ncv->dstheight % 2){
++ncv->dstheight;
}
int disprows = ncv->dstheight / 2;
int disprows = ncv->dstheight / 2 + ncv->dstheight % 2;
//fprintf(stderr, "MADE INITIAL ONE %d/%d\n", disprows, ncv->dstwidth);
ncv->ncp = ncplane_new(nc, disprows, ncv->dstwidth, 0, 0, NULL);
if(ncv->ncp == NULL){
ncvisual_destroy(ncv);
return NULL;
}
uint32_t* data = static_cast<uint32_t*>(malloc(rowstride * ncv->dstheight));
uint32_t* data = static_cast<uint32_t*>(memdup(rgba, rowstride * ncv->dstheight));
if(data == NULL){
ncvisual_destroy(ncv);
return NULL;
}
memcpy(data, rgba, rowstride * rows);
if(ncv->dstheight != rows){
memset(data + rows * (rowstride / 4), 0, rowstride);
}
ncv->data = data;
return ncv;
}
@ -243,10 +236,7 @@ ncvisual* ncvisual_from_bgra(notcurses* nc, const void* bgra, int rows,
ncv->ncobj = nc;
ncv->dstwidth = cols;
ncv->dstheight = rows;
if(ncv->dstheight % 2){
++ncv->dstheight;
}
int disprows = ncv->dstheight / 2;
int disprows = ncv->dstheight / 2 + ncv->dstheight % 2;
ncv->ncp = ncplane_new(nc, disprows, ncv->dstwidth, 0, 0, NULL);
if(ncv->ncp == NULL){
ncvisual_destroy(ncv);

Loading…
Cancel
Save