aboutsummaryrefslogtreecommitdiff
path: root/image.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-01-31 15:51:26 +0100
committerBert <ber.t@gmx.com>2011-01-31 15:51:26 +0100
commit802c3448793fdfd8255931235c40084558f7f515 (patch)
tree107e1a1013a14c4ba6c21a77670fbb118e32b6aa /image.c
parent16cc96eff5d858fe99b561459b7bce90fb64eeed (diff)
Check file timestamps before loading from cache
Diffstat (limited to 'image.c')
-rw-r--r--image.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/image.c b/image.c
index 83bd4b1..fd14ccc 100644
--- a/image.c
+++ b/image.c
@@ -52,22 +52,41 @@ void img_free(img_t* img) {
imlib_free_image();
}
+int img_check(const char *filename) {
+ Imlib_Image *im;
+
+ if (!filename)
+ return 0;
+
+ if (!(im = imlib_load_image(filename))) {
+ WARN("could not open image: %s", filename);
+ return 0;
+ }
+
+ imlib_context_set_image(im);
+ imlib_image_set_changes_on_disk();
+ imlib_free_image();
+
+ return 1;
+}
+
int img_load(img_t *img, const char *filename) {
Imlib_Image *im;
if (!img || !filename)
- return -1;
+ return 0;
if (imlib_context_get_image())
imlib_free_image();
if (!(im = imlib_load_image(filename))) {
WARN("could not open image: %s", filename);
- return -1;
+ return 0;
}
imlib_context_set_image(im);
imlib_context_set_anti_alias(img->aa);
+ imlib_image_set_changes_on_disk();
img->re = 0;
img->checkpan = 0;
@@ -76,7 +95,7 @@ int img_load(img_t *img, const char *filename) {
img->w = imlib_image_get_width();
img->h = imlib_image_get_height();
- return 0;
+ return 1;
}
void img_check_pan(img_t *img, win_t *win) {