[PATCH] load slide image on-demand

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sat, 4 Jun 2016 16:29:07 +0200

previously an image file would be opened but only ffread when advancing to
the slide, but when the slide was not used it gave an error:

        /usr/local/bin/2ff: failed to convert image/png

this changes it to load the image on-demand once and "cache" it.
---
 sent.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sent.c b/sent.c
index bde0de8..251524a 100644
--- a/sent.c
+++ b/sent.c
_AT_@ -55,6 +55,7 @@ typedef struct {
 	unsigned int linecount;
 	char **lines;
 	Image *img;
+	char *embed;
 } Slide;
 
 /* Purely graphic info */
_AT_@ -436,7 +437,7 @@ load(FILE *fp)
 			/* only make image slide if first line of a slide starts with _AT_ */
 			if (s->linecount == 0 && s->lines[0][0] == '_AT_') {
 				memmove(s->lines[0], &s->lines[0][1], blen);
-				s->img = ffopen(s->lines[0]);
+				s->embed = s->lines[0];
 			}
 
 			if (s->lines[s->linecount][0] == '\\')
_AT_@ -458,6 +459,8 @@ advance(const Arg *arg)
 		if (slides[idx].img)
 			slides[idx].img->state &= ~(DRAWN | SCALED);
 		idx = new_idx;
+		if (!slides[idx].img && slides[idx].embed && slides[idx].embed[0])
+			slides[idx].img = ffopen(slides[idx].embed);
 		xdraw();
 		if (slidecount > idx + 1 && slides[idx + 1].img)
 			ffread(slides[idx + 1].img);
-- 
2.8.1
-- 
Kind regards,
Hiltjo
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Sat Jun 04 2016 - 17:36:11 CEST