Skip to content

ncvisual_options used region not working #2892

@Ben0981

Description

@Ben0981

Hello, I have been trying to use the ncvisual_options to crop a resized image but no matter what I do the lenx leny begx begy parameters seem to be ignored.

Here is my code:

#include "notcurses/notcurses.h"

int main(int argc, char** argv) {

	notcurses_options opts = {};
	struct notcurses* nc = notcurses_init(&opts, NULL);

	struct ncplane* stdn = notcurses_stdplane(nc);

	struct ncvisual* img = ncvisual_from_file("image.png"); 

	ncvisual_resize(img, 400, 400);

	struct ncvisual_options imgOpts = {
		.y = 0, .x = 0,
		.begx = 0, .begy = 200,
		.lenx = 200, .leny = 200,
		.blitter = NCBLIT_PIXEL,
		.n = stdn,
		.flags = NCVISUAL_OPTION_CHILDPLANE,
	};

	struct ncplane* pixelPlane = ncvisual_blit(nc, img, &imgOpts);
	
	notcurses_render(nc);

	ncinput ni = {};
	notcurses_get_blocking(nc, &ni);

	notcurses_stop(nc);
	
	return 0;
}

What I would expect to happen here is a 200x200px subsection, showing the lower left quadrant, of the image being rendered, but what actually happens is the full 400x400px image being rendered (the same happens without the resize but larger). Setting these parameters to any other value also does not change what is rendered.

Looking at the man-pages my usage should be correct, with begy and begx setting the top left corner and leny and lenx setting the size of the rendered section.

I am not sure if I am using this wrong or if something isn't working but any help with this is much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    userquestionnot quite bugs--inquiries from users

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions