nsxivfdbc5cf
Added EXIF_SUPPORT macro for optional dependency on libexif
+42 −30
2 files changed
| @@ -18,7 +18,10 @@ | |||
| 18 | 18 | ||
| 19 | 19 | #include <string.h> | |
| 20 | 20 | #include <unistd.h> | |
| 21 | + | ||
| 22 | + | #ifdef EXIF_SUPPORT | |
| 21 | 23 | #include <libexif/exif-data.h> | |
| 24 | + | #endif | |
| 22 | 25 | ||
| 23 | 26 | #ifdef GIF_SUPPORT | |
| 24 | 27 | #include <stdlib.h> | |
| @@ -38,6 +41,29 @@ enum { MIN_GIF_DELAY = 50 }; | |||
| 38 | 41 | float zoom_min; | |
| 39 | 42 | float zoom_max; | |
| 40 | 43 | ||
| 44 | + | void img_init(img_t *img, win_t *win) { | |
| 45 | + | zoom_min = zoom_levels[0] / 100.0; | |
| 46 | + | zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0; | |
| 47 | + | ||
| 48 | + | if (img) { | |
| 49 | + | img->im = NULL; | |
| 50 | + | img->multi.cap = img->multi.cnt = 0; | |
| 51 | + | img->multi.animate = 0; | |
| 52 | + | img->zoom = options->zoom; | |
| 53 | + | img->zoom = MAX(img->zoom, zoom_min); | |
| 54 | + | img->zoom = MIN(img->zoom, zoom_max); | |
| 55 | + | img->aa = options->aa; | |
| 56 | + | img->alpha = 1; | |
| 57 | + | } | |
| 58 | + | ||
| 59 | + | if (win) { | |
| 60 | + | imlib_context_set_display(win->env.dpy); | |
| 61 | + | imlib_context_set_visual(win->env.vis); | |
| 62 | + | imlib_context_set_colormap(win->env.cmap); | |
| 63 | + | } | |
| 64 | + | } | |
| 65 | + | ||
| 66 | + | #ifdef EXIF_SUPPORT | |
| 41 | 67 | void exif_auto_orientate(const fileinfo_t *file) { | |
| 42 | 68 | ExifData *ed; | |
| 43 | 69 | ExifEntry *entry; | |
| @@ -80,28 +106,7 @@ void exif_auto_orientate(const fileinfo_t *file) { | |||
| 80 | 106 | break; | |
| 81 | 107 | } | |
| 82 | 108 | } | |
| 83 | − | ||
| 84 | − | void img_init(img_t *img, win_t *win) { | |
| 85 | − | zoom_min = zoom_levels[0] / 100.0; | |
| 86 | − | zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0; | |
| 87 | − | ||
| 88 | − | if (img) { | |
| 89 | − | img->im = NULL; | |
| 90 | − | img->multi.cap = img->multi.cnt = 0; | |
| 91 | − | img->multi.animate = 0; | |
| 92 | − | img->zoom = options->zoom; | |
| 93 | − | img->zoom = MAX(img->zoom, zoom_min); | |
| 94 | − | img->zoom = MIN(img->zoom, zoom_max); | |
| 95 | − | img->aa = options->aa; | |
| 96 | − | img->alpha = 1; | |
| 97 | − | } | |
| 98 | − | ||
| 99 | − | if (win) { | |
| 100 | − | imlib_context_set_display(win->env.dpy); | |
| 101 | − | imlib_context_set_visual(win->env.vis); | |
| 102 | − | imlib_context_set_colormap(win->env.cmap); | |
| 103 | − | } | |
| 104 | − | } | |
| 109 | + | #endif /* EXIF_SUPPORT */ | |
| 105 | 110 | ||
| 106 | 111 | #ifdef GIF_SUPPORT | |
| 107 | 112 | /* Originally based on, but in its current form merely inspired by Imlib2's | |
| @@ -285,14 +290,16 @@ int img_load(img_t *img, const fileinfo_t *file) { | |||
| 285 | 290 | imlib_context_set_anti_alias(img->aa); | |
| 286 | 291 | ||
| 287 | 292 | fmt = imlib_image_format(); | |
| 293 | + | /* avoid unused-but-set-variable warning */ | |
| 294 | + | (void) fmt; | |
| 295 | + | ||
| 296 | + | #ifdef EXIF_SUPPORT | |
| 288 | 297 | if (!strcmp(fmt, "jpeg")) | |
| 289 | 298 | exif_auto_orientate(file); | |
| 299 | + | #endif | |
| 290 | 300 | #ifdef GIF_SUPPORT | |
| 291 | 301 | if (!strcmp(fmt, "gif")) | |
| 292 | 302 | img_load_gif(img, file); | |
| 293 | − | #else | |
| 294 | − | /* avoid unused-but-set-variable warning */ | |
| 295 | − | (void) fmt; | |
| 296 | 303 | #endif | |
| 297 | 304 | ||
| 298 | 305 | img->scalemode = options->scalemode; | |
| @@ -34,7 +34,9 @@ | |||
| 34 | 34 | #define st_atim st_atimespec | |
| 35 | 35 | #endif | |
| 36 | 36 | ||
| 37 | + | #ifdef EXIF_SUPPORT | |
| 37 | 38 | void exif_auto_orientate(const fileinfo_t*); | |
| 39 | + | #endif | |
| 38 | 40 | ||
| 39 | 41 | const int thumb_dim = THUMB_SIZE + 10; | |
| 40 | 42 | char *cache_dir = NULL; | |
| @@ -255,11 +257,14 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file, | |||
| 255 | 257 | imlib_context_set_image(im); | |
| 256 | 258 | imlib_context_set_anti_alias(1); | |
| 257 | 259 | ||
| 258 | − | if (!cache_hit) { | |
| 259 | − | fmt = imlib_image_format(); | |
| 260 | − | if (!strcmp(fmt, "jpeg")) | |
| 261 | − | exif_auto_orientate(file); | |
| 262 | − | } | |
| 260 | + | fmt = imlib_image_format(); | |
| 261 | + | /* avoid unused-but-set-variable warning */ | |
| 262 | + | (void) fmt; | |
| 263 | + | ||
| 264 | + | #ifdef EXIF_SUPPORT | |
| 265 | + | if (!cache_hit !strcmp(fmt, "jpeg")) | |
| 266 | + | exif_auto_orientate(file); | |
| 267 | + | #endif | |
| 263 | 268 | ||
| 264 | 269 | w = imlib_image_get_width(); | |
| 265 | 270 | h = imlib_image_get_height(); | |