summaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-01-18 17:20:41 +0100
committerBert <ber.t@gmx.com>2011-01-18 17:20:41 +0100
commit2a2f0307c1e313dde979de2086d93971c57d342b (patch)
tree817cc6b6f61b993a64b75ea801c58a54db88665b /image.c
parent7121e7b468e133cda882c574bf1d6933c490ae94 (diff)
downloadnsxiv-2a2f0307c1e313dde979de2086d93971c57d342b.tar.zst
Basic image loading
Diffstat (limited to 'image.c')
-rw-r--r--image.c19
1 files changed, 18 insertions, 1 deletions
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 <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();
+}