ncls: update to prep_image() maxy/maxx #1661

This commit is contained in:
nick black 2021-05-18 03:28:50 -04:00 committed by Nick Black
parent 0e593502d4
commit 42f26fcb1e
4 changed files with 11 additions and 2 deletions

View File

@ -15,6 +15,11 @@ rearrangements of Notcurses.
* Fixed bad bug in `ncvisual_resize()` when growing an image. This isn't * Fixed bad bug in `ncvisual_resize()` when growing an image. This isn't
relevant to enlarging an `ncvisual` via scaling, but only when persistently relevant to enlarging an `ncvisual` via scaling, but only when persistently
growing one with `ncvisual_resize()`. growing one with `ncvisual_resize()`.
* Direct mode image rendering now honors the `maxy` and `maxx` parameters,
which specify the maximum number of cell rows and columns, respectively,
to use for the render. They were previously ignored, contrary to
documentation. It is now an error to pass a negative number for either of
these values. Use 0 to specify "as much space as is necessary".
* Added `ncdirectf_from_file()`, `ncdirectf_geom()`, and `ncdirectf_render()`, * Added `ncdirectf_from_file()`, `ncdirectf_geom()`, and `ncdirectf_render()`,
with the net result that you can now (efficiently) get media geometry in with the net result that you can now (efficiently) get media geometry in
direct mode. If you don't care about media geometry, you can keep using direct mode. If you don't care about media geometry, you can keep using

View File

@ -467,7 +467,7 @@ int ncdirect_render_image(struct ncdirect* nc, const char* filename,
// -- but will only occupy the column of the cursor, and those to the right. // -- but will only occupy the column of the cursor, and those to the right.
// To actually write (and free) this, invoke ncdirect_raster_frame(). 'maxx' // To actually write (and free) this, invoke ncdirect_raster_frame(). 'maxx'
// and 'maxy', if greater than 0, are used for scaling; the terminal's geometry // and 'maxy', if greater than 0, are used for scaling; the terminal's geometry
// is otherwise used. // is otherwise used. It is an error to pass a negative 'maxy' or 'maxx'.
ncdirectv* ncdirect_render_frame(struct ncdirect* n, const char* filename, ncdirectv* ncdirect_render_frame(struct ncdirect* n, const char* filename,
ncblitter_e blitter, ncscale_e scale, ncblitter_e blitter, ncscale_e scale,
int maxy, int maxx); int maxy, int maxx);

View File

@ -179,6 +179,10 @@ must be supplied to **ncdirect_init**.
before **NCBLIT_PIXEL** can be used to render images; see before **NCBLIT_PIXEL** can be used to render images; see
**notcurses_visual(3)** for more details. **notcurses_visual(3)** for more details.
When rendering an image, ***maxy*** and ***maxx*** specify a maximum number
of (cell) rows and columns to use, respectively. Passing 0 means "use as much
space as is necessary". It is an error to pass a negative number for either.
# RETURN VALUES # RETURN VALUES
**ncdirect_init** returns **NULL** on failure. Otherwise, the return value **ncdirect_init** returns **NULL** on failure. Otherwise, the return value

View File

@ -147,7 +147,7 @@ void ncls_thread(const lsContext* ctx) {
work.pop(); work.pop();
pthread_mutex_unlock(&mtx); pthread_mutex_unlock(&mtx);
auto s = j.dir / j.p; auto s = j.dir / j.p;
auto faken = ctx->nc.prep_image(s.c_str(), ctx->blitter, ctx->scaling, -1, -1); auto faken = ctx->nc.prep_image(s.c_str(), ctx->blitter, ctx->scaling, 0, 0);
pthread_mutex_lock(&outmtx); pthread_mutex_lock(&outmtx);
std::cout << j.p << '\n'; std::cout << j.p << '\n';
if(faken){ if(faken){