mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
ncdirect_render_image: fix NCSCALE_NONE #759
This commit is contained in:
parent
b829398538
commit
4c3cb44100
@ -245,12 +245,21 @@ int ncdirect_cursor_pop(ncdirect* n){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ncdirect_dump_plane(ncdirect* n, const ncplane* np){
|
ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){
|
||||||
const int totx = ncdirect_dim_x(n);
|
const int totx = ncdirect_dim_x(n);
|
||||||
const int toty = ncdirect_dim_y(n);
|
const int toty = ncdirect_dim_y(n);
|
||||||
int dimy, dimx;
|
int dimy, dimx;
|
||||||
ncplane_dim_yx(np, &dimy, &dimx);
|
ncplane_dim_yx(np, &dimy, &dimx);
|
||||||
|
fprintf(stderr, "rasterizing %dx%d\n", dimy, dimx);
|
||||||
for(int y = 0 ; y < dimy ; ++y){
|
for(int y = 0 ; y < dimy ; ++y){
|
||||||
|
if(ncdirect_cursor_move_yx(n, -1, xoff)){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for(int x = 0 ; x < xoff ; ++x){
|
||||||
|
if(putchar(' ') == EOF){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
for(int x = 0 ; x < dimx ; ++x){
|
for(int x = 0 ; x < dimx ; ++x){
|
||||||
uint32_t attrword;
|
uint32_t attrword;
|
||||||
uint64_t channels;
|
uint64_t channels;
|
||||||
@ -274,7 +283,6 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ncdirect_cursor_left(n, dimx);
|
|
||||||
if(y == toty){
|
if(y == toty){
|
||||||
ncdirect_cursor_down(n, 1);
|
ncdirect_cursor_down(n, 1);
|
||||||
}
|
}
|
||||||
@ -302,14 +310,15 @@ nc_err_e ncdirect_render_image(ncdirect* n, const char* file, ncalign_e align,
|
|||||||
return NCERR_INVALID_ARG;
|
return NCERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
int disprows, dispcols;
|
int disprows, dispcols;
|
||||||
disprows = ncdirect_dim_y(n);
|
|
||||||
dispcols = ncdirect_dim_x(n);
|
|
||||||
if(scale != NCSCALE_NONE){
|
if(scale != NCSCALE_NONE){
|
||||||
dispcols *= encoding_x_scale(bset);
|
dispcols = ncdirect_dim_x(n) * encoding_x_scale(bset);
|
||||||
disprows *= encoding_y_scale(bset);
|
disprows = ncdirect_dim_y(n) * encoding_y_scale(bset);
|
||||||
if(scale == NCSCALE_SCALE){
|
if(scale == NCSCALE_SCALE){
|
||||||
scale_visual(ncv, &disprows, &dispcols);
|
scale_visual(ncv, &disprows, &dispcols);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
disprows = ncv->rows;
|
||||||
|
dispcols = ncv->cols / encoding_x_scale(bset);
|
||||||
}
|
}
|
||||||
leny = (leny / (double)ncv->rows) * ((double)disprows);
|
leny = (leny / (double)ncv->rows) * ((double)disprows);
|
||||||
lenx = (lenx / (double)ncv->cols) * ((double)dispcols);
|
lenx = (lenx / (double)ncv->cols) * ((double)dispcols);
|
||||||
@ -328,7 +337,8 @@ nc_err_e ncdirect_render_image(ncdirect* n, const char* file, ncalign_e align,
|
|||||||
return NCERR_SYSTEM;
|
return NCERR_SYSTEM;
|
||||||
}
|
}
|
||||||
ncvisual_destroy(ncv);
|
ncvisual_destroy(ncv);
|
||||||
if(ncdirect_dump_plane(n, faken)){
|
int xoff = 0;
|
||||||
|
if(ncdirect_dump_plane(n, faken, xoff)){
|
||||||
return NCERR_SYSTEM;
|
return NCERR_SYSTEM;
|
||||||
}
|
}
|
||||||
free_plane(faken);
|
free_plane(faken);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user