static void filter_crop(context_t *cx) { unsigned int x, y, w, h; unsigned int xmin, xmax, ymin, ymax; xmin = w = caca_get_canvas_width(cx->torender); xmax = 0; ymin = h = caca_get_canvas_height(cx->torender); ymax = 0; for(y = 0; y < h; y++) for(x = 0; x < w; x++) { unsigned long int ch = caca_get_char(cx->torender, x, y); if(ch != (unsigned char)' ') { if(x < xmin) xmin = x; if(x > xmax) xmax = x; if(y < ymin) ymin = y; if(y > ymax) ymax = y; } } if(xmax < xmin || ymax < ymin) return; caca_set_canvas_boundaries(cx->torender, xmin, ymin, xmax - xmin + 1, ymax - ymin + 1); }
static void filter_border(context_t *cx) { int w, h; w = caca_get_canvas_width(cx->torender); h = caca_get_canvas_height(cx->torender); caca_set_canvas_boundaries(cx->torender, -1, -1, w + 2, h + 2); caca_draw_cp437_box(cx->torender, 0, 0, w + 2, h + 2); }
JNIEXPORT void JNICALL Java_org_zoy_caca_Canvas_setCanvasBoundaries(JNIEnv *env, jclass cls, jlong ptr, jint x, jint y, jint w, jint h) { caca_set_canvas_boundaries((caca_canvas_t *)ptr, x, y, w, h); }