[bitmaps] fix bitmap placement when making a new plane #1468

pull/1473/head
nick black 3 years ago committed by Nick Black
parent 229c1ab3c2
commit df85fb55ba

@ -1208,8 +1208,8 @@ impl NcPlane {
#[inline]
pub fn halign(&mut self, align: NcAlign, cols: NcDim) -> NcResult<()> {
error![
crate::ncplane_halign(self, halign, cols),
&format!("NcPlane.halign({:?}, {})", halign, cols)
crate::ncplane_halign(self, align, cols),
&format!("NcPlane.halign({:?}, {})", align, cols)
]
}
@ -1223,8 +1223,8 @@ impl NcPlane {
#[inline]
pub fn valign(&mut self, align: NcAlign, cols: NcDim) -> NcResult<()> {
error![
crate::ncplane_valign(self, valign, cols),
&format!("NcPlane.valign({:?}, {})", valign, cols)
crate::ncplane_valign(self, align, cols),
&format!("NcPlane.valign({:?}, {})", align, cols)
]
}

@ -508,6 +508,12 @@ ncplane* ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const struct blitse
return n;
}
// by the end, disprows/dispcols refer to the number of source rows/cols (in
// pixels), which will be mapped to a region of cells scaled by the encodings).
// the blit will begin at placey/placex (in terms of cells). begy/begx define
// the origin of the source region to draw (in pixels). leny/lenx defined the
// geometry of the source region to draw, again in pixels. ncv->rows and
// ncv->cols define the source geometry in pixels.
ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blitset* bset,
int placey, int placex, int begy, int begx,
ncplane* n, ncscale_e scaling, uint64_t flags){
@ -523,12 +529,17 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
}
//fprintf(stderr, "INPUT N: %p rows: %d cols: %d 0x%016lx\n", n ? n : NULL, disprows, dispcols, flags);
if(n == NULL){ // create plane
if(scaling != NCSCALE_NONE && scaling != NCSCALE_NONE_HIRES){
ncplane_dim_yx(stdn, &disprows, &dispcols);
if(scaling == NCSCALE_NONE || scaling == NCSCALE_NONE_HIRES){
dispcols = ncv->cols;
disprows = ncv->rows;
}else{
notcurses_term_dim_yx(nc, &disprows, &dispcols);
dispcols *= nc->tcache.cellpixx;
disprows *= nc->tcache.cellpixy;
if(scaling == NCSCALE_SCALE || scaling == NCSCALE_SCALE_HIRES){
scale_visual(ncv, &disprows, &dispcols);
} // else stretch
}
//fprintf(stderr, "PLACING NEW PLANE: %d/%d @ %d/%d\n", disprows, dispcols, placey, placex);
struct ncplane_options nopts = {
.y = placey,
.x = placex,
@ -545,6 +556,7 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
if(flags & NCVISUAL_OPTION_VERALIGNED){
nopts.flags |= NCPLANE_OPTION_VERALIGNED;
}
//fprintf(stderr, "PLACING NEW PLANE: %d/%d @ %d/%d 0x%016lx\n", nopts.rows, nopts.cols, nopts.y, nopts.x, nopts.flags);
if((n = ncplane_create(stdn, &nopts)) == NULL){
return NULL;
}

Loading…
Cancel
Save