Пример #1
0
int main(void)
{
    struct FTR f = ftr_new_window(320, 200);
    ftr_set_handler(&f, "idle", ftr_handler_stop_loop);
    ftr_loop_run(&f);
    return printf("finí!\n");
}
Пример #2
0
// main function
int main(int argc, char *argv[])
{
	if (argc != 2) {
		fprintf(stderr, "usage:\n\t%s [image.png]\n", *argv);
		return 1;
	}
	char *filename_in = argv[1];

	struct FTR f = ftr_new_window(512,512);
	struct viewer_state e[1];
	f.userdata = e;

	e->img = iio_read_image_float_vec(filename_in, &e->iw, &e->ih, &e->pd);


	center_view(&f);
	paint_state(&f);

	ftr_set_handler(&f, "key", event_key);
	ftr_set_handler(&f, "button", event_button);
	ftr_set_handler(&f, "motion", event_motion);
	ftr_set_handler(&f, "resize", event_resize);

	return ftr_loop_run(&f);
}
Пример #3
0
int main_pan(int c, char *v[])
{
	// process input arguments
	if (c != 2 && c != 1) {
		fprintf(stderr, "usage:\n\t%s [image]\n", *v);
		//                          0  1
		return 1;
	}
	char *filename_in = c > 1 ? v[1] : "-";

	// read image
	struct pan_state e[1];
	e->rgb = read_image_uint8_rgb(filename_in, &e->w, &e->h);
	create_pyramid(e);

	// open window
	struct FTR f = ftr_new_window(BAD_MIN(e->w,800), BAD_MIN(e->h,600));
	f.userdata = e;
	action_reset_zoom_and_position(&f);
	ftr_set_handler(&f, "expose", pan_exposer);
	ftr_set_handler(&f, "motion", pan_motion_handler);
	ftr_set_handler(&f, "button", pan_button_handler);
	ftr_set_handler(&f, "key", pan_key_handler);
	int r = ftr_loop_run(&f);

	// cleanup and exit (optional)
	ftr_close(&f);
	free(e->rgb);
	free_pyramid(e);
	return r;
}
Пример #4
0
int main_srt()
{
	struct terminal t[1];
	t->w = 80;
	t->h = 25;
	t->kerning = 0;
	t->spacing = 0;
	t->font[0] = reformat_font(*xfont_10x20, UNPACKED);
	fprintf(stderr, "NUMBER_OF_GLYPHS = %d\n", t->font->number_of_glyphs);
	t->letters    = calloc(t->w * t->h, sizeof*t->letters);
	t->attributes = calloc(t->w * t->h, sizeof*t->attributes);
	t->cursorx = t->cursory = 0;
	int w = (t->w + t->kerning) * t->font->width;
	int h = (t->h + t->spacing) * t->font->height;

	term_puts(t, "abc");

	struct FTR f = ftr_new_window(w, h);
	f.userdata = t;
	f.changed = 1;

	ftr_set_handler(&f, "expose", term_exposer);
	ftr_set_handler(&f, "key", term_key_handler);
	return ftr_loop_run(&f);
}
Пример #5
0
int main_pan(int c, char *v[])
{
	// process input arguments
	if (c != 3) {
		fprintf(stderr, "usage:\n\t%s left.png right.png\n", *v);
		//                          0 1        2
		return c;
	}
	char *filename_image  = v[1];
	char *filename_hough = v[2];

	// read images
	int w[2], h[2], pd[2];
	float *x[2];

	// read images into the "pan_state" struct
	struct pan_state e[1];
	e->image = iio_read_image_float_vec(filename_image,
			&e->image_w, &e->image_h, &e->image_pd);
	e->hough = iio_read_image_float_vec(filename_hough,
			&e->hough_w, &e->hough_h, &e->hough_pd);
	if (e->image_pd != 3 || e->hough_pd != 1)
		return fprintf(stderr, "I expect left=color & right=gray\n");

	// open windows, and cross-reference them with the state
	struct FTR f = ftr_new_window(e->image_w, e->image_h);
	struct FTR g = ftr_new_window(e->hough_w, e->hough_h);
	f.userdata = g.userdata = e;
	e->f = &f;
	e->g = &g;

	// set handlers
	ftr_set_handler(&f, "expose", pan_exposer_f);
	ftr_set_handler(&f, "motion", pan_motion_handler_f);
	ftr_set_handler(&g, "expose", pan_exposer_g);
	ftr_set_handler(&g, "motion", pan_motion_handler_g);

	// run event loop
	int r = ftr_loop_run2(&f, &g);

	// cleanup and exit (optional)
	ftr_close(&f);
	ftr_close(&g);
	free(e->image);
	free(e->hough);
	return r;
}
Пример #6
0
int main()
{
	struct FTR f = ftr_new_window(800, 600);
	for (int i = 0; i < 3 * f.w * f.h; i++)
		f.rgb[i] = rand();
	f.changed = 1;
	return ftr_loop_run(&f);;
}
Пример #7
0
int main_fpantiff(int c, char *v[])
{
	TIFFSetWarningHandler(NULL);//suppress warnings

	// process input arguments
	char *filename_preview = pick_option(&c, &v, "p", "");
	if (c != 2) {
		fprintf(stderr, "usage:\n\t%s pyrpattern\n", *v);
		//                          0 1
		return 1;
	}
	char *pyrpattern = v[1];

	// read image
	struct pan_state e[1];
	int megabytes = 100;
	tiff_octaves_init(e->t, pyrpattern, megabytes);
	e->w = 700;
	e->h = 500;
	e->infrared = 4 == e->t->i->spp;
	e->slog = false;
	e->preview = NULL;
	e->do_preview = false;
	e->a = 1;
	e->b = 0;
	if (*filename_preview) add_preview(e, filename_preview);

	// open window
	struct FTR f;
	if (e->preview)
		f = ftr_new_window(e->pw, e->ph);
	else
		f = ftr_new_window(BAD_MIN(e->w,700), BAD_MIN(e->h,500));
	f.userdata = e;
	action_reset_zoom_and_position(&f);
	ftr_set_handler(&f, "key"   , pan_key_handler);
	ftr_set_handler(&f, "button", pan_button_handler);
	ftr_set_handler(&f, "motion", pan_motion_handler);
	ftr_set_handler(&f, "expose", pan_exposer);
	int r = ftr_loop_run(&f);

	// cleanup and exit (optional)
	ftr_close(&f);
	return r;
}
Пример #8
0
int main_cpu(int c, char *v[])
{
	// extract named options
	char *window_title = pick_option(&c, &v, "t", "cpu");

	// process input arguments
	if (c != 2 && c != 1) {
		fprintf(stderr, "usage:\n\t%s [image]\n", *v);
		//                          0  1
		return 1;
	}
	char *filename_in = c > 1 ? v[1] : "-";

	// read image
	struct pan_state e[1];
	e->i = fancy_image_open(filename_in, "r");
	e->w = e->i->w;
	e->h = e->i->h;

	// setup fonts (TODO, integrate these calls into fontu's caching stuff)
	e->font[0] = reformat_font(*xfont_4x6, UNPACKED);
	e->font[1] = reformat_font(*xfont_6x12, UNPACKED);
	e->font[2] = reformat_font(*xfont_7x13, UNPACKED);
	e->font[3] = reformat_font(*xfont_9x15, UNPACKED);
	e->font[4] = reformat_font(*xfont_10x20, UNPACKED);
	//e->font[0] = reformat_font(*xfont_5x7, UNPACKED);

	// open window
	struct FTR f = ftr_new_window(BAD_MIN(e->w,1000), BAD_MIN(e->h,800));
	ftr_change_title(&f, window_title);
	f.userdata = e;
	action_reset_zoom_and_position(&f);
	ftr_set_handler(&f, "expose", pan_exposer);
	ftr_set_handler(&f, "motion", pan_motion_handler);
	ftr_set_handler(&f, "button", pan_button_handler);
	ftr_set_handler(&f, "key"   , pan_key_handler);
	int r = ftr_loop_run(&f);

	// cleanup and exit (optional)
	for (int i = 0; i < 5; i++) free(e->font[i].data);
	ftr_close(&f);
	fancy_image_close(e->i);
	return r - 1;
}
Пример #9
0
int main_fpanflip(int c, char *v[])
{
	// all input images are images to read
	int n = c - 1;
	char *fname[c];
	fname[0] = "-";
	for (int i = 0; i < n; i++)
		fname[i] = v[i+1];

	// read images
	struct pan_state e[1];
	e->n_images = n;
	e->current_image = 0;
	e->fix_viewports = 1;
	for (int i = 0; i < n; i++)
	{
		fprintf(stderr, "reading image %d \"%s\"\n", i, fname[i]);
		struct pan_image *x = e->t + i;
		x->frgb = read_image_float_rgb(fname[i], &x->w, &x->h);
		x->fname = fname[i];
		create_pyramid(x);
	}

	// open window and init state
	struct FTR f = ftr_new_window( BAD_MIN(e->t->w,1200),
					BAD_MIN(e->t->h,800) );
	f.userdata = e;
	action_reset_zoom_and_position(&f);

	// set handlers
	ftr_set_handler(&f, "expose", pan_exposer);
	ftr_set_handler(&f, "motion", pan_motion_handler);
	ftr_set_handler(&f, "button", pan_button_handler);
	ftr_set_handler(&f, "key"   , pan_key_handler);

	// run loop
	int r = ftr_loop_run(&f);

	// cleanup and exit (optional)
	ftr_close(&f);
	//free(e->frgb);
	//free_pyramid(e);
	return r;
}
Пример #10
0
int main()
{
	struct terminal t[1];
	t->w = 80;
	t->h = 25;
	t->kerning = 0;
	t->spacing = 0;
	t->font[0] = reformat_font(*xfont9x15, UNPACKED);
	t->letters = malloc(sizeof(int) * t->w * t->h);
	t->attributes = malloc(sizeof(int) * t->w * t->h);
	t->cursorx = t->cursory = 0;
	int w = (t->w + t->kerning) * t->font->width;
	int h = (t->h + t->spacing) * t->font->height;

	term_puts(t, "");

	struct FTR f = ftr_new_window(w, h);
	f.userdata = t;
	f.changed = 1;

	ftr_set_handler(&f, "expose", term_exposer);
	ftr_set_handler(&f, "key", term_key_handler);
	return ftr_loop_run(&f);
}
Пример #11
0
int main_pan(int c, char *v[])
{
	// process input arguments
	char *imask_option = pick_option(&c, &v, "m", "");
	if (c > 4) {
		fprintf(stderr, "usage:\n\t"
				"%s [in.fft [out.fft [out.mask]]]\n", *v);
		//                0  1       2        3
		return c;
	}
	char *filename_in   = c > 1 ? v[1] : "-";
	char *filename_out  = c > 2 ? v[2] : "-";
	char *filename_mask = c > 3 ? v[3] : NULL;
	char *filename_imask = *imask_option ? imask_option : NULL;


	// read image
	struct pan_state e[1];
	int pd;
	e->fft = (void*)iio_read_image_float_vec(filename_in, &e->w, &e->h,&pd);
	if (pd != 2 && pd != 6)
		return fprintf(stderr, "input must be a fft (got pd=%d)\n", pd);
	e->pd = pd / 2;
	create_pyramid(e);
	if (filename_imask) {
		int mw, mh;
		e->mask = iio_read_image_uint8(filename_imask,&mw,&mh);
		if (mw != e->w || mh != e->h)
			return fprintf(stderr, "input mask bad size\n");
		fprintf(stderr, "using input mask from file \"%s\"\n",
				filename_imask);
	} else {
		e->mask = malloc(e->w * e->h);
		memset(e->mask, 1, e->w * e->h);
	}

	// open window
	struct FTR f = ftr_new_window(BAD_MIN(e->w,512), BAD_MIN(e->h,512));
	f.userdata = e;
	action_reset_zoom_and_position(&f);
	ftr_set_handler(&f, "expose", pan_exposer);
	ftr_set_handler(&f, "motion", pan_motion_handler);
	ftr_set_handler(&f, "button", pan_button_handler);
	ftr_set_handler(&f, "key"   , pan_key_handler);
	int r = ftr_loop_run(&f);

	// apply computed mask
	for (int i = 0; i < e->w * e->h; i++)
		if (!e->mask[i])
			for (int l = 0; l < e->pd; l++)
				e->fft[i*e->pd+l] = 0;

	// save output images
	iio_save_image_float_vec(filename_out, (void*)e->fft, e->w,e->h, pd);
	if (filename_mask)
		iio_save_image_uint8_vec(filename_mask, e->mask, e->w, e->h, 1);

	// cleanup and exit (optional)
	ftr_close(&f);
	return r;
}