diff options
author | Bert <ber.t@gmx.com> | 2011-01-18 17:20:41 +0100 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-01-18 17:20:41 +0100 |
commit | 2a2f0307c1e313dde979de2086d93971c57d342b (patch) | |
tree | 817cc6b6f61b993a64b75ea801c58a54db88665b /image.c | |
parent | 7121e7b468e133cda882c574bf1d6933c490ae94 (diff) | |
download | nsxiv-2a2f0307c1e313dde979de2086d93971c57d342b.tar.zst |
Basic image loading
Diffstat (limited to 'image.c')
-rw-r--r-- | image.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -16,7 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <Imlib2.h> +#include <stdlib.h> +#include <stdio.h> #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(); +} |