Krolyxon
Commit fdbc5cf

Branches

Refs →

nsxivfdbc5cf

Added EXIF_SUPPORT macro for optional dependency on libexif

Author
Bert
Date
2011-09-08 15:55 +0200
Committer
Bert · 2011-09-08 15:58 +0200
Parent
bfab4dc
Commit
fdbc5cf76b547e60395027e60011d9f301bbb776

+42 −30

2 files changed

  1. M image.c +32 −25
  2. M thumbs.c +10 −5
M image.c View
@@ -18,7 +18,10 @@
1818
1919 #include <string.h>
2020 #include <unistd.h>
21+
22+#ifdef EXIF_SUPPORT
2123 #include <libexif/exif-data.h>
24+#endif
2225
2326 #ifdef GIF_SUPPORT
2427 #include <stdlib.h>
@@ -38,6 +41,29 @@ enum { MIN_GIF_DELAY = 50 };
3841 float zoom_min;
3942 float zoom_max;
4043
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
4167 void exif_auto_orientate(const fileinfo_t *file) {
4268 ExifData *ed;
4369 ExifEntry *entry;
@@ -80,28 +106,7 @@ void exif_auto_orientate(const fileinfo_t *file) {
80106 break;
81107 }
82108 }
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 */
105110
106111 #ifdef GIF_SUPPORT
107112 /* 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) {
285290 imlib_context_set_anti_alias(img->aa);
286291
287292 fmt = imlib_image_format();
293+ /* avoid unused-but-set-variable warning */
294+ (void) fmt;
295+
296+#ifdef EXIF_SUPPORT
288297 if (!strcmp(fmt, "jpeg"))
289298 exif_auto_orientate(file);
299+#endif
290300 #ifdef GIF_SUPPORT
291301 if (!strcmp(fmt, "gif"))
292302 img_load_gif(img, file);
293−#else
294− /* avoid unused-but-set-variable warning */
295− (void) fmt;
296303 #endif
297304
298305 img->scalemode = options->scalemode;
M thumbs.c View
@@ -34,7 +34,9 @@
3434 #define st_atim st_atimespec
3535 #endif
3636
37+#ifdef EXIF_SUPPORT
3738 void exif_auto_orientate(const fileinfo_t*);
39+#endif
3840
3941 const int thumb_dim = THUMB_SIZE + 10;
4042 char *cache_dir = NULL;
@@ -255,11 +257,14 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file,
255257 imlib_context_set_image(im);
256258 imlib_context_set_anti_alias(1);
257259
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
263268
264269 w = imlib_image_get_width();
265270 h = imlib_image_get_height();