From ddb0566f90ded0646a3f544715be418c50128bb4 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 2 Oct 2011 19:22:51 +0200 Subject: [PATCH] [wip] show_image(): Also take struct box --- src/terminal/image.c | 6 +++--- src/terminal/image.h | 3 ++- src/viewer/text/draw.c | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/terminal/image.c b/src/terminal/image.c index 579e6e6c..ebdcda6b 100644 --- a/src/terminal/image.c +++ b/src/terminal/image.c @@ -26,7 +26,7 @@ void -show_image(struct terminal *term, int imgid, int x, int y, struct cache_entry *ce, int w, int h) +show_image(struct terminal *term, int imgid, struct box *box, struct cache_entry *ce) { struct string s; int fd; @@ -56,8 +56,8 @@ show_image(struct terminal *term, int imgid, int x, int y, struct cache_entry *c if (!init_string(&s)) return; - add_format_to_string(&s, "%d %d %d %s %d %d", imgid, x, y, - term->imgfiles[imgid], w, h); + add_format_to_string(&s, "%d %d %d %s %d %d", imgid, box->x, box->y, + term->imgfiles[imgid], box->width, box->height); do_terminal_function(term, TERM_FN_IMG_DRAW, s.source); done_string(&s); } diff --git a/src/terminal/image.h b/src/terminal/image.h index a7f1604c..fc349e4f 100644 --- a/src/terminal/image.h +++ b/src/terminal/image.h @@ -1,10 +1,11 @@ #ifndef EL__TERMINAL_IMAGE_H #define EL__TERMINAL_IMAGE_H +struct box; struct cache_entry; struct terminal; -extern void show_image(struct terminal *term, int imgid, int x, int y, struct cache_entry *ce, int w, int h); +extern void show_image(struct terminal *term, int imgid, struct box *box, struct cache_entry *ce); extern void move_image(struct terminal *term, int imgid, int x, int y); extern void hide_image(struct terminal *term, int imgid); extern void sync_images(struct terminal *term); diff --git a/src/viewer/text/draw.c b/src/viewer/text/draw.c index d7a08408..2b20b380 100644 --- a/src/viewer/text/draw.c +++ b/src/viewer/text/draw.c @@ -197,6 +197,7 @@ draw_images(struct session *ses, struct document_view *doc_view, struct view_sta struct cache_entry *cached; int w = img->w, h = img->h; struct point spos = { .x = img->pos.x - vs_box.x, .y = img->pos.y - vs_box.y }; + struct box img_box; /* Fetch cache entry. */ cached = get_redirected_cache_entry(img->uri); @@ -212,9 +213,10 @@ draw_images(struct session *ses, struct document_view *doc_view, struct view_sta /* Trim image by bounding box. */ w = int_min(w, (box->width - spos.x) * chw); h = int_min(h, (box->height - spos.y) * chh); + /* Create box. */ + set_box(&img_box, (box->x + spos.x) * chw, (box->y + spos.y) * chh, w, h); - //printf("rim %d : %d %d : %d %d\n", cnt, (box->x + spos.x) * chw, (box->y + spos.y) * chh, w, h); - show_image(term, cnt++, (box->x + spos.x) * chw, (box->y + spos.y) * chh, cached, w, h); + show_image(term, cnt++, &img_box, cached); } } -- 2.11.4.GIT