From 2a2f0307c1e313dde979de2086d93971c57d342b Mon Sep 17 00:00:00 2001 From: Bert Date: Tue, 18 Jan 2011 17:20:41 +0100 Subject: Basic image loading --- image.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'image.c') diff --git a/image.c b/image.c index 2ffa07c..a2742f4 100644 --- a/image.c +++ b/image.c @@ -16,7 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include +#include #include "sxiv.h" #include "image.h" @@ -30,3 +31,19 @@ void imlib_init(win_t *win) { imlib_context_set_colormap(win->env.cmap); imlib_context_set_drawable(win->xwin); } + +void img_load(img_t *img, char *filename) { + if (!img || !filename) + return; + + if (imlib_context_get_image()) + imlib_free_image(); + + if (!(img->im = imlib_load_image(filename))) + FATAL("could not open image: %s", filename); + + imlib_context_set_image(img->im); + + img->w = imlib_image_get_width(); + img->h = imlib_image_get_height(); +} -- cgit v1.2.3