ncdirect_render_image(): just about working #725

pull/755/head
nick black 4 years ago committed by Nick Black
parent 277cbc9c16
commit 40d0efcece

@ -226,6 +226,7 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np){
}
ncdirect_fg(n, channels_fg(channels));
ncdirect_bg(n, channels_bg(channels));
// fprintf(stderr, "%03d/%03d [%s]\n", y, x, egc);
if(printf("%s", egc) < 0){
return -1;
}
@ -259,8 +260,8 @@ nc_err_e ncdirect_render_image(ncdirect* n, const char* file, ncblitter_e blitte
return NCERR_INVALID_ARG;
}
int disprows, dispcols;
dispcols = ncdirect_dim_x(n);
disprows = ncdirect_dim_y(n);
dispcols = ncdirect_dim_x(n);
if(scale != NCSCALE_NONE){
dispcols *= encoding_x_scale(bset);
disprows *= encoding_y_scale(bset);
@ -271,13 +272,13 @@ nc_err_e ncdirect_render_image(ncdirect* n, const char* file, ncblitter_e blitte
}
leny = (leny / (double)ncv->rows) * ((double)disprows);
lenx = (lenx / (double)ncv->cols) * ((double)dispcols);
//fprintf(stderr, "render: %dx%d:%d+%d of %d/%d stride %u %p\n", begy, begx, leny, lenx, ncv->rows, ncv->cols, ncv->rowstride, ncv->data);
fprintf(stderr, "render: %dx%d:%d+%d of %d/%d stride %u %p\n", begy, begx, leny, lenx, ncv->rows, ncv->cols, ncv->rowstride, ncv->data);
struct ncplane* faken = ncplane_create(NULL, NULL, disprows, dispcols, 0, 0, NULL);
if(faken == NULL){
return NCERR_NOMEM;
}
if(ncvisual_blit(ncv, disprows, dispcols, faken, bset,
begy, begx, begy, begx, leny, lenx,
0, 0, 0, 0, leny, lenx,
false)){
ncvisual_destroy(ncv);
free_plane(faken);

@ -1,4 +1,5 @@
#include <locale.h>
#include <unistd.h>
#include <notcurses/notcurses.h>
// can we leave what was already on the screen there? (narrator: it seems not)
@ -14,6 +15,10 @@ int main(void){
if(ncdirect_render_image(n, "../data/warmech.bmp", NCBLIT_DEFAULT, NCSCALE_STRETCH) != NCERR_SUCCESS){
return EXIT_FAILURE;
}
sleep(1);
if(ncdirect_render_image(n, "../data/worldmap.png", NCBLIT_DEFAULT, NCSCALE_STRETCH) != NCERR_SUCCESS){
return EXIT_FAILURE;
}
if(ncdirect_stop(n)){
return EXIT_FAILURE;
}

Loading…
Cancel
Save