Mercurial > geeqie
annotate src/image.c @ 426:9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
author | nadvornik |
---|---|
date | Sat, 19 Apr 2008 17:55:41 +0000 |
parents | 26c6e768bd47 |
children | a254a7102af5 |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
3 * (C) 2006 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
9 | 12 |
281 | 13 #include "main.h" |
1 | 14 #include "image.h" |
9 | 15 |
16 | |
17 #include "image-load.h" | |
18 #include "collect.h" | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
19 #include "color-man.h" |
9 | 20 #include "exif.h" |
415 | 21 #include "image-overlay.h" |
284 | 22 #include "layout.h" |
23 #include "layout_image.h" | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
24 #include "pixbuf-renderer.h" |
9 | 25 #include "pixbuf_util.h" |
26 #include "ui_fileops.h" | |
27 | |
138 | 28 #include "filelist.h" |
29 | |
9 | 30 #include <math.h> |
31 | |
32 | |
33 /* size of the image loader buffer (512 bytes x defined number) */ | |
34 #define IMAGE_LOAD_BUFFER_COUNT 8 | |
35 | |
36 /* define this so that more bytes are read per idle loop on larger images (> 1MB) */ | |
37 #define IMAGE_THROTTLE_LARGER_IMAGES 1 | |
38 | |
39 /* throttle factor to increase read bytes by (2 is double, 3 is triple, etc.) */ | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
40 #define IMAGE_THROTTLE_FACTOR 32 |
9 | 41 |
42 /* the file size at which throttling take place */ | |
43 #define IMAGE_THROTTLE_THRESHOLD 1048576 | |
44 | |
45 #define IMAGE_AUTO_REFRESH_TIME 3000 | |
46 | |
1 | 47 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
48 static GList *image_list = NULL; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
49 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
50 |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
51 static void image_update_title(ImageWindow *imd); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
52 static void image_post_process(ImageWindow *imd, gint clamp); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
53 static void image_read_ahead_start(ImageWindow *imd); |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
54 |
1 | 55 /* |
9 | 56 *------------------------------------------------------------------- |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
57 * 'signals' |
9 | 58 *------------------------------------------------------------------- |
59 */ | |
60 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
61 static void image_click_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data) |
9 | 62 { |
63 ImageWindow *imd = data; | |
64 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
65 if (imd->func_button) |
9 | 66 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
67 imd->func_button(imd, event->button, event->time, |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
68 event->x, event->y, event->state, imd->data_button); |
9 | 69 } |
70 } | |
71 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
72 static void image_drag_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
73 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
74 ImageWindow *imd = data; |
129 | 75 gint width, height; |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
76 |
129 | 77 pixbuf_renderer_get_scaled_size(pr, &width, &height); |
78 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
79 if (imd->func_drag) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
80 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
81 imd->func_drag(imd, event->button, event->time, |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
82 event->x, event->y, event->state, |
129 | 83 (gfloat)(pr->drag_last_x - event->x) / width, (gfloat)(pr->drag_last_y - event->y) / height, |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
84 imd->data_button); |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
85 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
86 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
87 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
88 static void image_scroll_notify_cb(PixbufRenderer *pr, gpointer data) |
9 | 89 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
90 ImageWindow *imd = data; |
9 | 91 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
92 if (imd->func_scroll_notify && pr->scale) |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
93 { |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
94 imd->func_scroll_notify(imd, |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
95 (gint)((gdouble)pr->x_scroll / pr->scale), |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
96 (gint)((gdouble)pr->y_scroll / pr->scale), |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
97 (gint)((gdouble)pr->image_width - pr->vis_width / pr->scale), |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
98 (gint)((gdouble)pr->image_height - pr->vis_height / pr->scale), |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
99 imd->data_scroll_notify); |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
100 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
101 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
102 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
103 static void image_update_util(ImageWindow *imd) |
1 | 104 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
105 if (imd->func_update) imd->func_update(imd, imd->data_update); |
9 | 106 } |
107 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
108 static void image_zoom_cb(PixbufRenderer *pr, gdouble zoom, gpointer data) |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
109 { |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
110 ImageWindow *imd = data; |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
111 |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
112 if (imd->title_show_zoom) image_update_title(imd); |
415 | 113 if (imd->overlay_show_zoom) image_osd_update(imd); |
114 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
115 image_update_util(imd); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
116 } |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
117 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
118 static void image_complete_util(ImageWindow *imd, gint preload) |
9 | 119 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
120 if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return; |
9 | 121 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
122 if (debug) printf("%s image load completed \"%s\" (%s)\n", get_exec_time(), |
203 | 123 (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") : |
124 (imd->image_fd ? imd->image_fd->path : "null"), | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
125 (preload) ? "preload" : "current"); |
9 | 126 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
127 if (!preload) imd->completed = TRUE; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
128 if (imd->func_complete) imd->func_complete(imd, preload, imd->data_complete); |
1 | 129 } |
130 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
131 static void image_render_complete_cb(PixbufRenderer *pr, gpointer data) |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
132 { |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
133 ImageWindow *imd = data; |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
134 |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
135 image_complete_util(imd, FALSE); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
136 } |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
137 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
138 static void image_state_set(ImageWindow *imd, ImageState state) |
9 | 139 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
140 if (state == IMAGE_STATE_NONE) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
141 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
142 imd->state = state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
143 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
144 else |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
145 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
146 imd->state |= state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
147 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
148 if (imd->func_state) imd->func_state(imd, state, imd->data_state); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
149 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
150 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
151 static void image_state_unset(ImageWindow *imd, ImageState state) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
152 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
153 imd->state &= ~state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
154 if (imd->func_state) imd->func_state(imd, state, imd->data_state); |
1 | 155 } |
156 | |
157 /* | |
9 | 158 *------------------------------------------------------------------- |
159 * misc | |
160 *------------------------------------------------------------------- | |
161 */ | |
162 | |
163 static void image_update_title(ImageWindow *imd) | |
1 | 164 { |
9 | 165 gchar *title = NULL; |
166 gchar *zoom = NULL; | |
167 gchar *collection = NULL; | |
168 | |
169 if (!imd->top_window) return; | |
170 | |
171 if (imd->collection && collection_to_number(imd->collection) >= 0) | |
172 { | |
173 const gchar *name; | |
174 name = imd->collection->name; | |
175 if (!name) name = _("Untitled"); | |
176 collection = g_strdup_printf(" (Collection %s)", name); | |
177 } | |
178 | |
179 if (imd->title_show_zoom) | |
1 | 180 { |
9 | 181 gchar *buf = image_zoom_get_as_text(imd); |
182 zoom = g_strconcat(" [", buf, "]", NULL); | |
183 g_free(buf); | |
1 | 184 } |
185 | |
9 | 186 title = g_strdup_printf("%s%s%s%s%s%s", |
187 imd->title ? imd->title : "", | |
138 | 188 imd->image_fd ? imd->image_fd->name : "", |
9 | 189 zoom ? zoom : "", |
190 collection ? collection : "", | |
138 | 191 imd->image_fd ? " - " : "", |
9 | 192 imd->title_right ? imd->title_right : ""); |
193 | |
194 gtk_window_set_title(GTK_WINDOW(imd->top_window), title); | |
195 | |
196 g_free(title); | |
197 g_free(zoom); | |
198 g_free(collection); | |
199 } | |
200 | |
201 /* | |
202 *------------------------------------------------------------------- | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
203 * rotation, flip, etc. |
9 | 204 *------------------------------------------------------------------- |
205 */ | |
206 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
207 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
208 #if 0 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
209 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
210 static void image_alter_real(ImageWindow *imd, AlterType type, gint clamp) |
9 | 211 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
212 PixbufRenderer *pr; |
9 | 213 GdkPixbuf *new = NULL; |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
214 gint exif_rotate; |
9 | 215 gint x, y; |
216 gint t; | |
217 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
218 pr = (PixbufRenderer *)imd->pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
219 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
220 exif_rotate = (imd->delay_alter_type != ALTER_NONE && (imd->state & IMAGE_STATE_ROTATE_AUTO)); |
9 | 221 imd->delay_alter_type = ALTER_NONE; |
222 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
223 if (!pr->pixbuf) return; |
9 | 224 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
225 x = pr->x_scroll + (pr->vis_width / 2); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
226 y = pr->y_scroll + (pr->vis_height / 2); |
9 | 227 |
228 switch (type) | |
229 { | |
230 case ALTER_ROTATE_90: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
231 new = pixbuf_copy_rotate_90(pr->pixbuf, FALSE); |
9 | 232 t = x; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
233 x = pr->height - y; |
9 | 234 y = t; |
235 break; | |
236 case ALTER_ROTATE_90_CC: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
237 new = pixbuf_copy_rotate_90(pr->pixbuf, TRUE); |
9 | 238 t = x; |
239 x = y; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
240 y = pr->width - t; |
9 | 241 break; |
242 case ALTER_ROTATE_180: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
243 new = pixbuf_copy_mirror(pr->pixbuf, TRUE, TRUE); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
244 x = pr->width - x; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
245 y = pr->height - y; |
9 | 246 break; |
247 case ALTER_MIRROR: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
248 new = pixbuf_copy_mirror(pr->pixbuf, TRUE, FALSE); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
249 x = pr->width - x; |
9 | 250 break; |
251 case ALTER_FLIP: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
252 new = pixbuf_copy_mirror(pr->pixbuf, FALSE, TRUE); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
253 y = pr->height - y; |
9 | 254 break; |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
255 case ALTER_DESATURATE: |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
256 pixbuf_desaturate_rect(pr->pixbuf, |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
257 0, 0, pr->image_width, pr->image_height); |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
258 image_area_changed(imd, 0, 0, pr->image_width, pr->image_height); |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
244
diff
changeset
|
259 layout_image_overlay_update(layout_find_by_image(imd)); |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
260 break; |
9 | 261 case ALTER_NONE: |
262 default: | |
263 return; | |
264 break; | |
265 } | |
266 | |
267 if (!new) return; | |
268 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
269 pixbuf_renderer_set_pixbuf(pr, new, pr->zoom); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
270 g_object_unref(new); |
9 | 271 |
109
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
272 if (clamp && pr->zoom != 0.0 && pr->scale != 0.0) |
9 | 273 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
274 if (exif_rotate) |
109
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
275 { |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
276 switch (pr->scroll_reset) |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
277 { |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
278 case PR_SCROLL_RESET_NOCHANGE: |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
279 break; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
280 case PR_SCROLL_RESET_CENTER: |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
281 x = (gint)((gdouble)pr->image_width / 2.0 * pr->scale); |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
282 y = (gint)((gdouble)pr->image_height / 2.0 * pr->scale); |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
283 break; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
284 case PR_SCROLL_RESET_TOPLEFT: |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
285 default: |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
286 x = 0; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
287 y = 0; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
288 break; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
289 } |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
290 } |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
291 pixbuf_renderer_scroll_to_point(pr, (gint)((gdouble)x / pr->scale), |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
292 (gint)((gdouble)y / pr->scale), |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
293 0.50, 0.50); |
9 | 294 } |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
295 |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
296 if (exif_rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO); |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
244
diff
changeset
|
297 layout_image_overlay_update(layout_find_by_image(imd)); |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
298 if (debug) printf("%s image postprocess done: %s\n", get_exec_time(), imd->image_fd->name); |
1 | 299 } |
300 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
301 static void image_post_process_alter(ImageWindow *imd, gint clamp) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
302 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
303 if (imd->delay_alter_type != ALTER_NONE) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
304 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
305 image_alter_real(imd, imd->delay_alter_type, clamp); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
306 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
307 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
308 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
309 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
310 static void image_post_process_color_cb(ColorMan *cm, ColorManReturnType type, gpointer data) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
311 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
312 ImageWindow *imd = data; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
313 |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
314 color_man_free(cm); |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
315 if (type == COLOR_RETURN_IMAGE_CHANGED) |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
316 { |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
317 if (cm == imd->cm) imd->cm = NULL; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
318 return; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
319 } |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
320 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
321 imd->cm = NULL; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
322 image_state_set(imd, IMAGE_STATE_COLOR_ADJ); |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
323 if (debug) printf("%s image postprocess cm done: %s\n", get_exec_time(), imd->image_fd->name); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
324 |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
325 image_post_process_alter(imd, FALSE); |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
326 |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
327 image_read_ahead_start(imd); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
328 } |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
329 #endif |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
330 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
331 static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData *exif, gint run_in_bg) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
332 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
333 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
334 ColorManProfileType input_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
335 ColorManProfileType screen_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
336 const gchar *input_file; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
337 const gchar *screen_file; |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
338 ExifItem *item = NULL; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
339 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
340 if (imd->cm) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
341 |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
342 if (imd->color_profile_input >= COLOR_PROFILE_FILE && |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
343 imd->color_profile_input < COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
344 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
345 gint n; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
346 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
347 n = imd->color_profile_input - 1; |
327 | 348 if (!options->color_profile.input_file[n]) return FALSE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
349 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
350 input_type = COLOR_PROFILE_FILE; |
327 | 351 input_file = options->color_profile.input_file[n]; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
352 } |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
353 else if (imd->color_profile_input >= COLOR_PROFILE_SRGB && |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
354 imd->color_profile_input < COLOR_PROFILE_FILE) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
355 { |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
356 input_type = imd->color_profile_input; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
357 input_file = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
358 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
359 else |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
360 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
361 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
362 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
363 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
364 if (imd->color_profile_screen == 1 && |
327 | 365 options->color_profile.screen_file) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
366 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
367 screen_type = COLOR_PROFILE_FILE; |
327 | 368 screen_file = options->color_profile.screen_file; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
369 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
370 else if (imd->color_profile_screen == 0) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
371 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
372 screen_type = COLOR_PROFILE_SRGB; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
373 screen_file = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
374 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
375 else |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
376 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
377 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
378 } |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
379 imd->color_profile_from_image = COLOR_PROFILE_NONE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
380 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
381 if (imd->color_profile_use_image && exif) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
382 { |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
209
diff
changeset
|
383 item = exif_get_item(exif, "Exif.Image.InterColorProfile"); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
384 if (!item) |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
385 { |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
386 gint cs; |
424 | 387 gchar *interop_index; |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
388 |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
389 /* ColorSpace == 1 specifies sRGB per EXIF 2.2 */ |
424 | 390 if (!exif_get_integer(exif, "Exif.Photo.ColorSpace", &cs)) cs = 0; |
391 interop_index = exif_get_data_as_text(exif, "Exif.Iop.InteroperabilityIndex"); | |
392 | |
393 if (cs == 1) | |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
394 { |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
395 input_type = COLOR_PROFILE_SRGB; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
396 input_file = NULL; |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
397 imd->color_profile_from_image = COLOR_PROFILE_SRGB; |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
398 |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
399 if (debug) printf("Found EXIF ColorSpace of sRGB\n"); |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
400 } |
424 | 401 if (cs == 2 || (interop_index && !strcmp(interop_index, "R03"))) |
402 { | |
403 input_type = COLOR_PROFILE_ADOBERGB; | |
404 input_file = NULL; | |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
405 imd->color_profile_from_image = COLOR_PROFILE_ADOBERGB; |
424 | 406 |
407 if (debug) printf("Found EXIF ColorSpace of AdobeRGB\n"); | |
408 } | |
409 | |
410 g_free(interop_index); | |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
411 } |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
412 } |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
413 |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
414 if (item && exif_item_get_format_id(item) == EXIF_FORMAT_UNDEFINED) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
415 { |
244 | 416 unsigned char *data; |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
417 guint data_len; |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
418 if (debug) printf("Found embedded color profile\n"); |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
419 imd->color_profile_from_image = COLOR_PROFILE_MEM; |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
420 |
244 | 421 data = (unsigned char *) exif_item_get_data(item, &data_len); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
422 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
423 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
424 data, data_len, |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
425 screen_type, screen_file); |
414
49c1cbe058ae
partially fixed reading embedded color profiles with exiv2
nadvornik
parents:
398
diff
changeset
|
426 g_free(data); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
427 } |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
428 else |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
429 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
430 cm = color_man_new(run_in_bg ? imd : NULL, NULL, |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
431 input_type, input_file, |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
432 screen_type, screen_file); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
433 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
434 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
435 if (cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
436 { |
116
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
437 if (start_row > 0) |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
438 { |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
439 cm->row = start_row; |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
440 cm->incremental_sync = TRUE; |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
441 } |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
442 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
443 imd->cm = (gpointer)cm; |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
444 #if 0 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
445 if (run_in_bg) color_man_start_bg(imd->cm, image_post_process_color_cb, imd); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
446 #endif |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
447 return TRUE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
448 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
449 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
450 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
451 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
452 |
9 | 453 static void image_post_process(ImageWindow *imd, gint clamp) |
454 { | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
455 #if 0 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
456 ExifData *exif = NULL; |
109
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
457 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
458 if (!image_get_pixbuf(imd)) return; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
459 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
460 if (debug) printf("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name); |
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
461 |
334 | 462 if (options->image.exif_rotate_enable || |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
463 (imd->color_profile_enable && imd->color_profile_use_image) ) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
464 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
181
diff
changeset
|
465 exif = exif_read_fd(imd->image_fd, (imd->color_profile_enable && imd->color_profile_use_image)); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
466 } |
334 | 467 if (options->image.exif_rotate_enable && exif) |
9 | 468 { |
469 gint orientation; | |
470 | |
180 | 471 if (exif_get_integer(exif, "Exif.Image.Orientation", &orientation)) |
9 | 472 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
473 gint rotate = TRUE; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
474 |
9 | 475 /* see http://jpegclub.org/exif_orientation.html |
476 1 2 3 4 5 6 7 8 | |
477 | |
478 888888 888888 88 88 8888888888 88 88 8888888888 | |
479 88 88 88 88 88 88 88 88 88 88 88 88 | |
480 8888 8888 8888 8888 88 8888888888 8888888888 88 | |
481 88 88 88 88 | |
482 88 88 888888 888888 | |
483 */ | |
484 switch (orientation) | |
485 { | |
486 case EXIF_ORIENTATION_TOP_LEFT: | |
487 /* normal -- nothing to do */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
488 rotate = FALSE; |
9 | 489 break; |
490 case EXIF_ORIENTATION_TOP_RIGHT: | |
491 /* mirrored */ | |
492 imd->delay_alter_type = ALTER_MIRROR; | |
493 break; | |
494 case EXIF_ORIENTATION_BOTTOM_RIGHT: | |
495 /* upside down */ | |
496 imd->delay_alter_type = ALTER_ROTATE_180; | |
497 break; | |
498 case EXIF_ORIENTATION_BOTTOM_LEFT: | |
499 /* flipped */ | |
500 imd->delay_alter_type = ALTER_FLIP; | |
501 break; | |
502 case EXIF_ORIENTATION_LEFT_TOP: | |
503 /* not implemented -- too wacky to fix in one step */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
504 rotate = FALSE; |
9 | 505 break; |
506 case EXIF_ORIENTATION_RIGHT_TOP: | |
507 /* rotated -90 (270) */ | |
508 imd->delay_alter_type = ALTER_ROTATE_90; | |
509 break; | |
510 case EXIF_ORIENTATION_RIGHT_BOTTOM: | |
511 /* not implemented -- too wacky to fix in one step */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
512 rotate = FALSE; |
9 | 513 break; |
514 case EXIF_ORIENTATION_LEFT_BOTTOM: | |
515 /* rotated 90 */ | |
516 imd->delay_alter_type = ALTER_ROTATE_90_CC; | |
517 break; | |
518 default: | |
519 /* The other values are out of range */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
520 rotate = FALSE; |
9 | 521 break; |
522 } | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
523 |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
524 if (rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO); |
9 | 525 } |
526 } | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
527 if (imd->color_profile_enable) |
9 | 528 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
529 if (!image_post_process_color(imd, 0, exif, TRUE)) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
530 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
531 /* fixme: note error to user */ |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
532 image_state_set(imd, IMAGE_STATE_COLOR_ADJ); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
533 } |
9 | 534 } |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
535 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
536 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
537 if (!imd->cm) image_post_process_alter(imd, clamp); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
538 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
539 exif_free(exif); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
540 #endif |
9 | 541 } |
542 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
543 static void image_post_process_tile_color_cb(PixbufRenderer *pr, GdkPixbuf **pixbuf, gint x, gint y, gint w, gint h, gpointer data) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
544 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
545 ImageWindow *imd = (ImageWindow *)data; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
546 if (imd->cm) color_man_correct_region(imd->cm, *pixbuf, x, y, w, h); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
547 if (imd->desaturate) pixbuf_desaturate_rect(*pixbuf, x, y, w, h); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
548 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
549 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
550 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
551 void image_alter(ImageWindow *imd, AlterType type) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
552 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
553 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
554 const static gint rotate_90[] = {1, 6, 7, 8, 5, 2, 3, 4, 1}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
555 const static gint rotate_90_cc[] = {1, 8, 5, 6, 7, 4, 1, 2, 3}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
556 const static gint rotate_180[] = {1, 3, 4, 1, 2, 7, 8, 5, 6}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
557 const static gint mirror[] = {1, 2, 1, 4, 3, 6, 5, 8, 7}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
558 const static gint flip[] = {1, 4, 3, 2, 1, 8, 7, 6, 5}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
559 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
560 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
561 if (!imd || !imd->pr) return; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
562 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
563 if (imd->orientation < 1 || imd->orientation > 8) imd->orientation = 1; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
564 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
565 switch (type) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
566 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
567 case ALTER_ROTATE_90: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
568 imd->orientation = rotate_90[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
569 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
570 case ALTER_ROTATE_90_CC: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
571 imd->orientation = rotate_90_cc[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
572 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
573 case ALTER_ROTATE_180: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
574 imd->orientation = rotate_180[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
575 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
576 case ALTER_MIRROR: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
577 imd->orientation = mirror[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
578 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
579 case ALTER_FLIP: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
580 imd->orientation = flip[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
581 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
582 case ALTER_DESATURATE: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
583 imd->desaturate = !imd->desaturate; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
584 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
585 case ALTER_NONE: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
586 default: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
587 return; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
588 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
589 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
590 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
591 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
592 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
593 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
594 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
595 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
596 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
597 |
9 | 598 /* |
599 *------------------------------------------------------------------- | |
600 * read ahead (prebuffer) | |
601 *------------------------------------------------------------------- | |
602 */ | |
603 | |
604 static void image_read_ahead_cancel(ImageWindow *imd) | |
605 { | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
606 if (debug) printf("%s read ahead cancelled for :%s\n", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null"); |
9 | 607 |
608 image_loader_free(imd->read_ahead_il); | |
609 imd->read_ahead_il = NULL; | |
610 | |
611 if (imd->read_ahead_pixbuf) g_object_unref(imd->read_ahead_pixbuf); | |
612 imd->read_ahead_pixbuf = NULL; | |
613 | |
138 | 614 file_data_unref(imd->read_ahead_fd); |
615 imd->read_ahead_fd = NULL; | |
9 | 616 } |
617 | |
618 static void image_read_ahead_done_cb(ImageLoader *il, gpointer data) | |
619 { | |
620 ImageWindow *imd = data; | |
621 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
622 if (debug) printf("%s read ahead done for :%s\n", get_exec_time(), imd->read_ahead_fd->path); |
9 | 623 |
624 imd->read_ahead_pixbuf = image_loader_get_pixbuf(imd->read_ahead_il); | |
625 if (imd->read_ahead_pixbuf) | |
626 { | |
627 g_object_ref(imd->read_ahead_pixbuf); | |
628 } | |
629 else | |
630 { | |
631 imd->read_ahead_pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); | |
632 } | |
633 image_loader_free(imd->read_ahead_il); | |
634 imd->read_ahead_il = NULL; | |
635 | |
636 image_complete_util(imd, TRUE); | |
637 } | |
638 | |
639 static void image_read_ahead_error_cb(ImageLoader *il, gpointer data) | |
640 { | |
641 /* we even treat errors as success, maybe at least some of the file was ok */ | |
642 image_read_ahead_done_cb(il, data); | |
643 } | |
644 | |
645 static void image_read_ahead_start(ImageWindow *imd) | |
646 { | |
647 /* already started ? */ | |
138 | 648 if (!imd->read_ahead_fd || imd->read_ahead_il || imd->read_ahead_pixbuf) return; |
9 | 649 |
650 /* still loading ?, do later */ | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
651 if (imd->il /*|| imd->cm*/) return; |
9 | 652 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
653 if (debug) printf("%s read ahead started for :%s\n", get_exec_time(), imd->read_ahead_fd->path); |
9 | 654 |
138 | 655 imd->read_ahead_il = image_loader_new(imd->read_ahead_fd); |
9 | 656 |
657 image_loader_set_error_func(imd->read_ahead_il, image_read_ahead_error_cb, imd); | |
658 if (!image_loader_start(imd->read_ahead_il, image_read_ahead_done_cb, imd)) | |
659 { | |
660 image_read_ahead_cancel(imd); | |
661 image_complete_util(imd, TRUE); | |
662 } | |
663 } | |
664 | |
138 | 665 static void image_read_ahead_set(ImageWindow *imd, FileData *fd) |
9 | 666 { |
138 | 667 if (imd->read_ahead_fd && fd && imd->read_ahead_fd == fd) return; |
9 | 668 |
669 image_read_ahead_cancel(imd); | |
670 | |
138 | 671 imd->read_ahead_fd = file_data_ref(fd); |
9 | 672 |
138 | 673 if (debug) printf("read ahead set to :%s\n", imd->read_ahead_fd->path); |
9 | 674 |
675 image_read_ahead_start(imd); | |
676 } | |
677 | |
678 /* | |
679 *------------------------------------------------------------------- | |
680 * post buffering | |
681 *------------------------------------------------------------------- | |
682 */ | |
683 | |
138 | 684 static void image_post_buffer_set(ImageWindow *imd, FileData *fd, GdkPixbuf *pixbuf, gint color_row) |
9 | 685 { |
138 | 686 file_data_unref(imd->prev_fd); |
9 | 687 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); |
688 | |
138 | 689 if (fd && pixbuf) |
9 | 690 { |
138 | 691 imd->prev_fd = file_data_ref(fd); |
9 | 692 |
693 g_object_ref(pixbuf); | |
694 imd->prev_pixbuf = pixbuf; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
695 imd->prev_color_row = color_row; |
9 | 696 } |
697 else | |
698 { | |
138 | 699 imd->prev_fd = NULL; |
9 | 700 imd->prev_pixbuf = NULL; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
701 imd->prev_color_row = -1; |
9 | 702 } |
703 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
704 if (debug) printf("%s post buffer set: %s\n", get_exec_time(), fd ? fd->path : "null"); |
9 | 705 } |
706 | |
707 static gint image_post_buffer_get(ImageWindow *imd) | |
708 { | |
709 gint success; | |
710 | |
711 if (imd->prev_pixbuf && | |
138 | 712 imd->image_fd && imd->prev_fd && imd->image_fd == imd->prev_fd) |
9 | 713 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
714 image_change_pixbuf(imd, imd->prev_pixbuf, image_zoom_get(imd)); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
715 if (imd->prev_color_row >= 0) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
716 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
717 ExifData *exif = NULL; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
718 |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
181
diff
changeset
|
719 if (imd->color_profile_use_image) exif = exif_read_fd(imd->image_fd, TRUE); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
720 // image_post_process_color(imd, imd->prev_color_row, exif, TRUE); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
721 exif_free(exif); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
722 } |
9 | 723 success = TRUE; |
724 } | |
725 else | |
726 { | |
727 success = FALSE; | |
728 } | |
729 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
730 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); |
9 | 731 imd->prev_pixbuf = NULL; |
732 | |
138 | 733 file_data_unref(imd->prev_fd); |
734 imd->prev_fd = NULL; | |
9 | 735 |
736 return success; | |
737 } | |
738 | |
739 /* | |
740 *------------------------------------------------------------------- | |
741 * loading | |
742 *------------------------------------------------------------------- | |
743 */ | |
744 | |
745 static void image_load_pixbuf_ready(ImageWindow *imd) | |
746 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
747 if (image_get_pixbuf(imd) || !imd->il) return; |
9 | 748 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
749 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 750 } |
751 | |
752 static void image_load_area_cb(ImageLoader *il, guint x, guint y, guint w, guint h, gpointer data) | |
753 { | |
754 ImageWindow *imd = data; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
755 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
756 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
757 pr = (PixbufRenderer *)imd->pr; |
9 | 758 |
759 if (imd->delay_flip && | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
760 pr->pixbuf != image_loader_get_pixbuf(il)) |
9 | 761 { |
762 return; | |
763 } | |
764 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
765 if (!pr->pixbuf) image_load_pixbuf_ready(imd); |
9 | 766 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
767 pixbuf_renderer_area_changed(pr, x, y, w, h); |
9 | 768 } |
769 | |
770 static void image_load_done_cb(ImageLoader *il, gpointer data) | |
1 | 771 { |
772 ImageWindow *imd = data; | |
9 | 773 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
774 if (debug) printf ("%s image done\n", get_exec_time()); |
9 | 775 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
776 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
777 image_state_unset(imd, IMAGE_STATE_LOADING); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
778 |
9 | 779 if (imd->delay_flip && |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
780 image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) |
9 | 781 { |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
29
diff
changeset
|
782 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
783 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 784 } |
785 | |
786 image_loader_free(imd->il); | |
787 imd->il = NULL; | |
788 | |
789 image_post_process(imd, TRUE); | |
790 | |
791 image_read_ahead_start(imd); | |
792 } | |
793 | |
794 static void image_load_error_cb(ImageLoader *il, gpointer data) | |
795 { | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
796 if (debug) printf ("%s image error\n", get_exec_time()); |
9 | 797 |
798 /* even on error handle it like it was done, | |
799 * since we have a pixbuf with _something_ */ | |
800 | |
801 image_load_done_cb(il, data); | |
802 } | |
803 | |
804 #ifdef IMAGE_THROTTLE_LARGER_IMAGES | |
805 static void image_load_buffer_throttle(ImageLoader *il) | |
806 { | |
807 if (!il || il->bytes_total < IMAGE_THROTTLE_THRESHOLD) return; | |
808 | |
809 /* Larger image files usually have larger chunks of data per pixel... | |
810 * So increase the buffer read size so that the rendering chunks called | |
811 * are also larger. | |
812 */ | |
813 | |
814 image_loader_set_buffer_size(il, IMAGE_LOAD_BUFFER_COUNT * IMAGE_THROTTLE_FACTOR); | |
815 } | |
816 #endif | |
817 | |
818 /* this read ahead is located here merely for the callbacks, above */ | |
819 | |
820 static gint image_read_ahead_check(ImageWindow *imd) | |
821 { | |
138 | 822 if (!imd->read_ahead_fd) return FALSE; |
9 | 823 if (imd->il) return FALSE; |
824 | |
138 | 825 if (!imd->image_fd || imd->read_ahead_fd != imd->image_fd) |
9 | 826 { |
827 image_read_ahead_cancel(imd); | |
828 return FALSE; | |
829 } | |
830 | |
831 if (imd->read_ahead_il) | |
832 { | |
833 imd->il = imd->read_ahead_il; | |
834 imd->read_ahead_il = NULL; | |
835 | |
836 /* override the old signals */ | |
837 image_loader_set_area_ready_func(imd->il, image_load_area_cb, imd); | |
838 image_loader_set_error_func(imd->il, image_load_error_cb, imd); | |
839 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT); | |
840 | |
841 #ifdef IMAGE_THROTTLE_LARGER_IMAGES | |
842 image_load_buffer_throttle(imd->il); | |
843 #endif | |
844 | |
845 /* do this one directly (probably should add a set func) */ | |
846 imd->il->func_done = image_load_done_cb; | |
847 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
848 g_object_set(G_OBJECT(imd->pr), "loading", TRUE, NULL); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
849 image_state_set(imd, IMAGE_STATE_LOADING); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
850 |
9 | 851 if (!imd->delay_flip) |
852 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
853 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 854 } |
855 | |
856 image_read_ahead_cancel(imd); | |
857 return TRUE; | |
858 } | |
859 else if (imd->read_ahead_pixbuf) | |
860 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
861 image_change_pixbuf(imd, imd->read_ahead_pixbuf, image_zoom_get(imd)); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
862 g_object_unref(imd->read_ahead_pixbuf); |
9 | 863 imd->read_ahead_pixbuf = NULL; |
864 | |
865 image_read_ahead_cancel(imd); | |
866 | |
867 image_post_process(imd, FALSE); | |
868 return TRUE; | |
869 } | |
870 | |
871 image_read_ahead_cancel(imd); | |
872 return FALSE; | |
873 } | |
874 | |
138 | 875 static gint image_load_begin(ImageWindow *imd, FileData *fd) |
9 | 876 { |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
877 if (debug) printf ("%s image begin \n", get_exec_time()); |
9 | 878 |
879 if (imd->il) return FALSE; | |
880 | |
881 imd->completed = FALSE; | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
882 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL); |
9 | 883 |
884 if (image_post_buffer_get(imd)) | |
885 { | |
138 | 886 if (debug) printf("from post buffer: %s\n", imd->image_fd->path); |
9 | 887 return TRUE; |
888 } | |
889 | |
890 if (image_read_ahead_check(imd)) | |
891 { | |
138 | 892 if (debug) printf("from read ahead buffer: %s\n", imd->image_fd->path); |
9 | 893 return TRUE; |
894 } | |
895 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
896 if (!imd->delay_flip && image_get_pixbuf(imd)) |
9 | 897 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
898 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
899 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
900 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
901 if (pr->pixbuf) g_object_unref(pr->pixbuf); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
902 pr->pixbuf = NULL; |
9 | 903 } |
904 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
905 g_object_set(G_OBJECT(imd->pr), "loading", TRUE, NULL); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
906 |
138 | 907 imd->il = image_loader_new(fd); |
9 | 908 |
909 image_loader_set_area_ready_func(imd->il, image_load_area_cb, imd); | |
910 image_loader_set_error_func(imd->il, image_load_error_cb, imd); | |
911 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT); | |
912 | |
913 if (!image_loader_start(imd->il, image_load_done_cb, imd)) | |
914 { | |
915 if (debug) printf("image start error\n"); | |
916 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
917 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
918 |
9 | 919 image_loader_free(imd->il); |
920 imd->il = NULL; | |
921 | |
922 image_complete_util(imd, FALSE); | |
923 | |
924 return FALSE; | |
925 } | |
926 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
927 image_state_set(imd, IMAGE_STATE_LOADING); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
928 |
9 | 929 #ifdef IMAGE_THROTTLE_LARGER_IMAGES |
930 image_load_buffer_throttle(imd->il); | |
931 #endif | |
932 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
933 if (!imd->delay_flip && !image_get_pixbuf(imd)) image_load_pixbuf_ready(imd); |
9 | 934 |
935 return TRUE; | |
936 } | |
937 | |
938 static void image_reset(ImageWindow *imd) | |
939 { | |
940 /* stops anything currently being done */ | |
941 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
942 if (debug) printf("%s image reset\n", get_exec_time()); |
9 | 943 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
944 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
945 |
9 | 946 image_loader_free(imd->il); |
947 imd->il = NULL; | |
948 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
949 color_man_free((ColorMan *)imd->cm); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
950 imd->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
951 |
9 | 952 imd->delay_alter_type = ALTER_NONE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
953 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
954 image_state_set(imd, IMAGE_STATE_NONE); |
9 | 955 } |
956 | |
957 /* | |
958 *------------------------------------------------------------------- | |
959 * image changer | |
960 *------------------------------------------------------------------- | |
961 */ | |
962 | |
963 static void image_change_complete(ImageWindow *imd, gdouble zoom, gint new) | |
964 { | |
965 image_reset(imd); | |
966 | |
138 | 967 if (imd->image_fd && isfile(imd->image_fd->path)) |
9 | 968 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
969 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
970 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
971 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
972 pr->zoom = zoom; /* store the zoom, needed by the loader */ |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
973 |
138 | 974 if (image_load_begin(imd, imd->image_fd)) |
9 | 975 { |
976 imd->unknown = FALSE; | |
977 } | |
978 else | |
979 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
980 GdkPixbuf *pixbuf; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
981 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
982 pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
983 image_change_pixbuf(imd, pixbuf, zoom); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
984 g_object_unref(pixbuf); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
985 |
9 | 986 imd->unknown = TRUE; |
987 } | |
138 | 988 imd->size = filesize(imd->image_fd->path); |
989 imd->mtime = filetime(imd->image_fd->path); | |
9 | 990 } |
991 else | |
992 { | |
138 | 993 if (imd->image_fd) |
9 | 994 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
995 GdkPixbuf *pixbuf; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
996 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
997 pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
998 image_change_pixbuf(imd, pixbuf, zoom); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
999 g_object_unref(pixbuf); |
138 | 1000 imd->mtime = filetime(imd->image_fd->path); |
9 | 1001 } |
1002 else | |
1003 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1004 image_change_pixbuf(imd, NULL, zoom); |
9 | 1005 imd->mtime = 0; |
1006 } | |
1007 imd->unknown = TRUE; | |
1008 imd->size = 0; | |
1009 } | |
1010 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1011 image_update_util(imd); |
9 | 1012 } |
1013 | |
138 | 1014 static void image_change_real(ImageWindow *imd, FileData *fd, |
9 | 1015 CollectionData *cd, CollectInfo *info, gdouble zoom) |
1016 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1017 GdkPixbuf *pixbuf; |
9 | 1018 GdkPixbuf *prev_pixbuf = NULL; |
138 | 1019 FileData *prev_fd = NULL; |
9 | 1020 gint prev_clear = FALSE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1021 gint prev_color_row = -1; |
9 | 1022 |
1023 imd->collection = cd; | |
1024 imd->collection_info = info; | |
1025 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1026 pixbuf = image_get_pixbuf(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1027 |
334 | 1028 if (options->image.enable_read_ahead && imd->image_fd && pixbuf) |
9 | 1029 { |
1030 if (imd->il) | |
1031 { | |
1032 /* current image is not finished */ | |
1033 prev_clear = TRUE; | |
1034 } | |
1035 else | |
1036 { | |
138 | 1037 prev_fd = file_data_ref(imd->image_fd); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1038 prev_pixbuf = pixbuf; |
9 | 1039 g_object_ref(prev_pixbuf); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1040 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1041 if (imd->cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1042 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1043 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1044 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1045 cm = (ColorMan *)imd->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1046 prev_color_row = cm->row; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1047 } |
9 | 1048 } |
1049 } | |
1050 | |
138 | 1051 file_data_unref(imd->image_fd); |
1052 imd->image_fd = file_data_ref(fd); | |
9 | 1053 |
1054 image_change_complete(imd, zoom, TRUE); | |
1055 | |
1056 if (prev_pixbuf) | |
1057 { | |
138 | 1058 image_post_buffer_set(imd, prev_fd, prev_pixbuf, prev_color_row); |
1059 file_data_unref(prev_fd); | |
9 | 1060 g_object_unref(prev_pixbuf); |
1061 } | |
1062 else if (prev_clear) | |
1063 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1064 image_post_buffer_set(imd, NULL, NULL, -1); |
9 | 1065 } |
1066 | |
1067 image_update_title(imd); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1068 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1069 } |
1070 | |
1071 /* | |
1072 *------------------------------------------------------------------- | |
1073 * focus stuff | |
1074 *------------------------------------------------------------------- | |
1075 */ | |
1076 | |
1077 static void image_focus_paint(ImageWindow *imd, gint has_focus, GdkRectangle *area) | |
1078 { | |
1079 GtkWidget *widget; | |
1080 | |
1081 widget = imd->widget; | |
1082 if (!widget->window) return; | |
1083 | |
1084 if (has_focus) | |
1085 { | |
1086 gtk_paint_focus (widget->style, widget->window, GTK_STATE_ACTIVE, | |
1087 area, widget, "image_window", | |
1088 widget->allocation.x, widget->allocation.y, | |
1089 widget->allocation.width - 1, widget->allocation.height - 1); | |
1090 } | |
1091 else | |
1092 { | |
1093 gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, | |
1094 area, widget, "image_window", | |
1095 widget->allocation.x, widget->allocation.y, | |
1096 widget->allocation.width - 1, widget->allocation.height - 1); | |
1097 } | |
1098 } | |
1099 | |
1100 static gint image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) | |
1101 { | |
1102 ImageWindow *imd = data; | |
1103 | |
1104 image_focus_paint(imd, GTK_WIDGET_HAS_FOCUS(widget), &event->area); | |
1105 return TRUE; | |
1106 } | |
1107 | |
1108 static gint image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
1109 { | |
1110 ImageWindow *imd = data; | |
1111 | |
1112 GTK_WIDGET_SET_FLAGS(imd->widget, GTK_HAS_FOCUS); | |
1113 image_focus_paint(imd, TRUE, NULL); | |
1114 | |
1115 return TRUE; | |
1116 } | |
1117 | |
1118 static gint image_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
1119 { | |
1120 ImageWindow *imd = data; | |
1121 | |
1122 GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS); | |
1123 image_focus_paint(imd, FALSE, NULL); | |
1124 | |
1125 return TRUE; | |
1126 } | |
1127 | |
1128 gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y, | |
1129 gint relative, gint always) | |
1130 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1131 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, relative, always); |
9 | 1132 } |
1133 | |
1134 void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y) | |
1135 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1136 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y); |
9 | 1137 } |
1138 | |
1139 gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y) | |
1140 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1141 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y); |
9 | 1142 } |
1143 | |
1144 void image_overlay_remove(ImageWindow *imd, gint id) | |
1145 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1146 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id); |
9 | 1147 } |
1148 | |
1149 static gint image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data) | |
1150 { | |
1151 ImageWindow *imd = data; | |
1152 | |
1153 if (imd->func_scroll && | |
1154 event && event->type == GDK_SCROLL) | |
1155 { | |
1156 imd->func_scroll(imd, event->direction, event->time, | |
1157 event->x, event->y, event->state, imd->data_scroll); | |
1158 return TRUE; | |
1159 } | |
1160 | |
1161 return FALSE; | |
1162 } | |
1163 | |
1164 /* | |
1165 *------------------------------------------------------------------- | |
1166 * public interface | |
1167 *------------------------------------------------------------------- | |
1168 */ | |
1169 | |
1170 void image_attach_window(ImageWindow *imd, GtkWidget *window, | |
1171 const gchar *title, const gchar *title_right, gint show_zoom) | |
1 | 1172 { |
1173 imd->top_window = window; | |
1174 g_free(imd->title); | |
9 | 1175 imd->title = g_strdup(title); |
1176 g_free(imd->title_right); | |
1177 imd->title_right = g_strdup(title_right); | |
1178 imd->title_show_zoom = show_zoom; | |
1179 | |
334 | 1180 if (!options->image.fit_window_to_image) window = NULL; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1181 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1182 pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)window); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1183 |
9 | 1184 image_update_title(imd); |
1185 } | |
1186 | |
1187 void image_set_update_func(ImageWindow *imd, | |
1188 void (*func)(ImageWindow *imd, gpointer data), | |
1189 gpointer data) | |
1190 { | |
1191 imd->func_update = func; | |
1192 imd->data_update = data; | |
1 | 1193 } |
1194 | |
9 | 1195 void image_set_complete_func(ImageWindow *imd, |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1196 void (*func)(ImageWindow *imd, gint preload, gpointer data), |
9 | 1197 gpointer data) |
1 | 1198 { |
9 | 1199 imd->func_complete = func; |
1200 imd->data_complete = data; | |
1 | 1201 } |
1202 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1203 void image_set_state_func(ImageWindow *imd, |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1204 void (*func)(ImageWindow *imd, ImageState state, gpointer data), |
9 | 1205 gpointer data) |
1 | 1206 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1207 imd->func_state = func; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1208 imd->data_state = data; |
9 | 1209 } |
1210 | |
1211 | |
1212 void image_set_button_func(ImageWindow *imd, | |
1213 void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gpointer), | |
1214 gpointer data) | |
1215 { | |
1216 imd->func_button = func; | |
1217 imd->data_button = data; | |
1218 } | |
1219 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1220 void image_set_drag_func(ImageWindow *imd, |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1221 void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy, gpointer), |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1222 gpointer data) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1223 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1224 imd->func_drag = func; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1225 imd->data_drag = data; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1226 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1227 |
9 | 1228 void image_set_scroll_func(ImageWindow *imd, |
1229 void (*func)(ImageWindow *, GdkScrollDirection direction, guint32 time, gdouble x, gdouble y, guint state, gpointer), | |
1230 gpointer data) | |
1 | 1231 { |
9 | 1232 imd->func_scroll = func; |
1233 imd->data_scroll = data; | |
1 | 1234 } |
1235 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1236 void image_set_scroll_notify_func(ImageWindow *imd, |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1237 void (*func)(ImageWindow *imd, gint x, gint y, gint width, gint height, gpointer data), |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1238 gpointer data) |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1239 { |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1240 imd->func_scroll_notify = func; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1241 imd->data_scroll_notify = data; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1242 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1243 |
9 | 1244 /* path, name */ |
1245 | |
1246 const gchar *image_get_path(ImageWindow *imd) | |
1247 { | |
138 | 1248 if (imd->image_fd == NULL) return NULL; |
1249 return imd->image_fd->path; | |
9 | 1250 } |
1251 | |
1252 const gchar *image_get_name(ImageWindow *imd) | |
1253 { | |
138 | 1254 if (imd->image_fd == NULL) return NULL; |
1255 return imd->image_fd->name; | |
1256 } | |
1257 | |
1258 FileData *image_get_fd(ImageWindow *imd) | |
1259 { | |
1260 return imd->image_fd; | |
9 | 1261 } |
1262 | |
1263 /* merely changes path string, does not change the image! */ | |
138 | 1264 void image_set_fd(ImageWindow *imd, FileData *fd) |
1 | 1265 { |
138 | 1266 file_data_unref(imd->image_fd); |
1267 imd->image_fd = file_data_ref(fd); | |
9 | 1268 |
1269 image_update_title(imd); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1270 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1271 } |
1272 | |
1273 /* load a new image */ | |
1274 | |
138 | 1275 void image_change_fd(ImageWindow *imd, FileData *fd, gdouble zoom) |
9 | 1276 { |
138 | 1277 if (imd->image_fd == fd) return; |
9 | 1278 |
138 | 1279 image_change_real(imd, fd, NULL, NULL, zoom); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1280 } |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1281 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1282 GdkPixbuf *image_get_pixbuf(ImageWindow *imd) |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1283 { |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1284 return pixbuf_renderer_get_pixbuf((PixbufRenderer *)imd->pr); |
9 | 1285 } |
1286 | |
1287 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom) | |
1288 { | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1289 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1290 ExifData *exif = NULL; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1291 gint orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1292 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1293 if (options->image.exif_rotate_enable || |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1294 (imd->color_profile_enable && imd->color_profile_use_image) ) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1295 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1296 exif = exif_read_fd(imd->image_fd, (imd->color_profile_enable && imd->color_profile_use_image)); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1297 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1298 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1299 if (options->image.exif_rotate_enable && exif && exif_get_integer(exif, "Exif.Image.Orientation", &orientation)) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1300 imd->orientation = orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1301 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1302 imd->orientation = 1; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1303 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1304 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, FALSE); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1305 if (imd->cm) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1306 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1307 color_man_free(imd->cm); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1308 imd->cm = NULL; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1309 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1310 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1311 pixbuf_renderer_set_pixbuf((PixbufRenderer *)imd->pr, pixbuf, zoom); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1312 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1313 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1314 if (imd->color_profile_enable) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1315 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1316 if (!image_post_process_color(imd, 0, exif, FALSE)) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1317 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1318 /* fixme: note error to user */ |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1319 // image_state_set(imd, IMAGE_STATE_COLOR_ADJ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1320 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1321 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1322 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1323 exif_free(exif); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1324 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1325 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1326 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1327 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1328 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1329 } |
1330 | |
1331 void image_change_from_collection(ImageWindow *imd, CollectionData *cd, CollectInfo *info, gdouble zoom) | |
1332 { | |
1333 if (!cd || !info || !g_list_find(cd->list, info)) return; | |
1334 | |
138 | 1335 image_change_real(imd, info->fd, cd, info, zoom); |
9 | 1336 } |
1337 | |
1338 CollectionData *image_get_collection(ImageWindow *imd, CollectInfo **info) | |
1339 { | |
1340 if (collection_to_number(imd->collection) >= 0) | |
1341 { | |
1342 if (g_list_find(imd->collection->list, imd->collection_info) != NULL) | |
1343 { | |
1344 if (info) *info = imd->collection_info; | |
1345 } | |
1346 else | |
1347 { | |
1348 if (info) *info = NULL; | |
1349 } | |
1350 return imd->collection; | |
1351 } | |
1352 | |
1353 if (info) *info = NULL; | |
1354 return NULL; | |
1355 } | |
1356 | |
1357 static void image_loader_sync_data(ImageLoader *il, gpointer data) | |
1358 { | |
1359 /* change data for the callbacks directly */ | |
1360 | |
1361 il->data_area_ready = data; | |
1362 il->data_error = data; | |
1363 il->data_done = data; | |
1364 il->data_percent = data; | |
1 | 1365 } |
1366 | |
9 | 1367 /* this is more like a move function |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1368 * it moves most data from source to imd |
9 | 1369 */ |
1370 void image_change_from_image(ImageWindow *imd, ImageWindow *source) | |
1371 { | |
1372 if (imd == source) return; | |
1373 | |
1374 imd->unknown = source->unknown; | |
1375 | |
1376 imd->collection = source->collection; | |
1377 imd->collection_info = source->collection_info; | |
1378 imd->size = source->size; | |
1379 imd->mtime = source->mtime; | |
1380 | |
138 | 1381 image_set_fd(imd, image_get_fd(source)); |
9 | 1382 |
1383 image_loader_free(imd->il); | |
1384 imd->il = NULL; | |
1385 | |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1386 if (source->il) |
9 | 1387 { |
1388 imd->il = source->il; | |
1389 source->il = NULL; | |
1390 | |
1391 image_loader_sync_data(imd->il, imd); | |
1392 | |
1393 imd->delay_alter_type = source->delay_alter_type; | |
1394 source->delay_alter_type = ALTER_NONE; | |
1395 } | |
1396 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1397 imd->color_profile_enable = source->color_profile_enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1398 imd->color_profile_input = source->color_profile_input; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1399 imd->color_profile_screen = source->color_profile_screen; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1400 imd->color_profile_use_image = source->color_profile_use_image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1401 color_man_free((ColorMan *)imd->cm); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1402 imd->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1403 if (source->cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1404 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1405 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1406 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1407 imd->cm = source->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1408 source->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1409 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1410 cm = (ColorMan *)imd->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1411 cm->imd = imd; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1412 cm->func_done_data = imd; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1413 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1414 |
9 | 1415 image_loader_free(imd->read_ahead_il); |
1416 imd->read_ahead_il = source->read_ahead_il; | |
1417 source->read_ahead_il = NULL; | |
1418 if (imd->read_ahead_il) image_loader_sync_data(imd->read_ahead_il, imd); | |
1419 | |
1420 if (imd->read_ahead_pixbuf) g_object_unref(imd->read_ahead_pixbuf); | |
1421 imd->read_ahead_pixbuf = source->read_ahead_pixbuf; | |
1422 source->read_ahead_pixbuf = NULL; | |
1423 | |
138 | 1424 file_data_unref(imd->read_ahead_fd); |
1425 imd->read_ahead_fd = source->read_ahead_fd; | |
1426 source->read_ahead_fd = NULL; | |
9 | 1427 |
1428 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); | |
1429 imd->prev_pixbuf = source->prev_pixbuf; | |
1430 source->prev_pixbuf = NULL; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1431 imd->prev_color_row = source->prev_color_row; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1432 source->prev_color_row = -1; |
9 | 1433 |
138 | 1434 file_data_unref(imd->prev_fd); |
1435 imd->prev_fd = source->prev_fd; | |
1436 source->prev_fd = NULL; | |
9 | 1437 |
1438 imd->completed = source->completed; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1439 imd->state = source->state; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1440 source->state = IMAGE_STATE_NONE; |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1441 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1442 imd->orientation = source->orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1443 imd->desaturate = source->desaturate; |
9 | 1444 |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1445 pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr)); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1446 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1447 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1448 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1449 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1450 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1451 |
9 | 1452 } |
1453 | |
1454 /* manipulation */ | |
1455 | |
1456 void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height) | |
1457 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1458 pixbuf_renderer_area_changed((PixbufRenderer *)imd->pr, x, y, width, height); |
9 | 1459 } |
1460 | |
1461 void image_reload(ImageWindow *imd) | |
1462 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1463 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1464 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1465 image_change_complete(imd, image_zoom_get(imd), FALSE); |
9 | 1466 } |
1467 | |
1468 void image_scroll(ImageWindow *imd, gint x, gint y) | |
1469 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1470 pixbuf_renderer_scroll((PixbufRenderer *)imd->pr, x, y); |
9 | 1471 } |
1472 | |
13
ef790149ae21
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
12
diff
changeset
|
1473 void image_scroll_to_point(ImageWindow *imd, gint x, gint y, |
ef790149ae21
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
12
diff
changeset
|
1474 gdouble x_align, gdouble y_align) |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1475 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1476 pixbuf_renderer_scroll_to_point((PixbufRenderer *)imd->pr, x, y, x_align, y_align); |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1477 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1478 |
131 | 1479 void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y) |
1480 { | |
1481 pixbuf_renderer_get_scroll_center(PIXBUF_RENDERER(imd->pr), x, y); | |
1482 } | |
1483 | |
1484 void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y) | |
1485 { | |
1486 pixbuf_renderer_set_scroll_center(PIXBUF_RENDERER(imd->pr), x, y); | |
1487 } | |
1488 | |
1489 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1490 #if 0 |
9 | 1491 void image_alter(ImageWindow *imd, AlterType type) |
1 | 1492 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1493 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1494 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1495 if (imd->il || imd->cm) |
9 | 1496 { |
1497 /* still loading, wait till done */ | |
1498 imd->delay_alter_type = type; | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1499 image_state_set(imd, IMAGE_STATE_ROTATE_USER); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1500 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1501 if (imd->cm && (imd->state & IMAGE_STATE_ROTATE_AUTO)) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1502 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1503 image_state_unset(imd, IMAGE_STATE_ROTATE_AUTO); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1504 } |
9 | 1505 return; |
1506 } | |
1507 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1508 image_alter_real(imd, type, TRUE); |
9 | 1509 } |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1510 #endif |
9 | 1511 |
1512 void image_zoom_adjust(ImageWindow *imd, gdouble increment) | |
1513 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1514 pixbuf_renderer_zoom_adjust((PixbufRenderer *)imd->pr, increment); |
9 | 1515 } |
1516 | |
1517 void image_zoom_adjust_at_point(ImageWindow *imd, gdouble increment, gint x, gint y) | |
1518 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1519 pixbuf_renderer_zoom_adjust_at_point((PixbufRenderer *)imd->pr, increment, x, y); |
9 | 1520 } |
1521 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1522 void image_zoom_set_limits(ImageWindow *imd, gdouble min, gdouble max) |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1523 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1524 pixbuf_renderer_zoom_set_limits((PixbufRenderer *)imd->pr, min, max); |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1525 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1526 |
9 | 1527 void image_zoom_set(ImageWindow *imd, gdouble zoom) |
1528 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1529 pixbuf_renderer_zoom_set((PixbufRenderer *)imd->pr, zoom); |
9 | 1530 } |
1531 | |
1532 void image_zoom_set_fill_geometry(ImageWindow *imd, gint vertical) | |
1533 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1534 PixbufRenderer *pr; |
9 | 1535 gdouble zoom; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1536 gint width, height; |
9 | 1537 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1538 pr = (PixbufRenderer *)imd->pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1539 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1540 if (!pixbuf_renderer_get_pixbuf(pr) || |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1541 !pixbuf_renderer_get_image_size(pr, &width, &height)) return; |
9 | 1542 |
1543 if (vertical) | |
1544 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1545 zoom = (gdouble)pr->window_height / height; |
9 | 1546 } |
1547 else | |
1548 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1549 zoom = (gdouble)pr->window_width / width; |
9 | 1550 } |
1551 | |
1552 if (zoom < 1.0) | |
1553 { | |
1554 zoom = 0.0 - 1.0 / zoom; | |
1 | 1555 } |
9 | 1556 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1557 pixbuf_renderer_zoom_set(pr, zoom); |
9 | 1558 } |
1559 | |
1560 gdouble image_zoom_get(ImageWindow *imd) | |
1561 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1562 return pixbuf_renderer_zoom_get((PixbufRenderer *)imd->pr); |
9 | 1563 } |
1564 | |
1565 gdouble image_zoom_get_real(ImageWindow *imd) | |
1566 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1567 return pixbuf_renderer_zoom_get_scale((PixbufRenderer *)imd->pr); |
9 | 1568 } |
1569 | |
1570 gchar *image_zoom_get_as_text(ImageWindow *imd) | |
1571 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1572 gdouble zoom; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1573 gdouble scale; |
9 | 1574 gdouble l = 1.0; |
1575 gdouble r = 1.0; | |
1576 gint pl = 0; | |
1577 gint pr = 0; | |
1578 gchar *approx = " "; | |
1579 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1580 zoom = image_zoom_get(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1581 scale = image_zoom_get_real(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1582 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1583 if (zoom > 0.0) |
1 | 1584 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1585 l = zoom; |
9 | 1586 } |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1587 else if (zoom < 0.0) |
9 | 1588 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1589 r = 0.0 - zoom; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1590 } |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1591 else if (zoom == 0.0 && scale != 0.0) |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1592 { |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1593 if (scale >= 1.0) |
9 | 1594 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1595 l = scale; |
9 | 1596 } |
1597 else | |
1598 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1599 r = 1.0 / scale; |
9 | 1600 } |
415 | 1601 approx = "~"; |
9 | 1602 } |
1603 | |
1604 if (rint(l) != l) pl = 1; | |
1605 if (rint(r) != r) pr = 1; | |
1606 | |
1607 return g_strdup_printf("%.*f :%s%.*f", pl, l, approx, pr, r); | |
1608 } | |
1609 | |
1610 gdouble image_zoom_get_default(ImageWindow *imd, gint mode) | |
1611 { | |
1612 gdouble zoom; | |
1613 | |
1614 if (mode == ZOOM_RESET_ORIGINAL) | |
1615 { | |
1616 zoom = 1.0; | |
1617 } | |
1618 else if (mode == ZOOM_RESET_FIT_WINDOW) | |
1619 { | |
1620 zoom = 0.0; | |
1 | 1621 } |
1622 else | |
1623 { | |
1624 if (imd) | |
1625 { | |
9 | 1626 zoom = image_zoom_get(imd); |
1 | 1627 } |
1628 else | |
1629 { | |
9 | 1630 zoom = 1.0; |
1 | 1631 } |
1632 } | |
1633 | |
1634 return zoom; | |
1635 } | |
1636 | |
9 | 1637 /* read ahead */ |
1638 | |
138 | 1639 void image_prebuffer_set(ImageWindow *imd, FileData *fd) |
9 | 1640 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1641 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1642 |
138 | 1643 if (fd) |
9 | 1644 { |
138 | 1645 image_read_ahead_set(imd, fd); |
9 | 1646 } |
1647 else | |
1648 { | |
1649 image_read_ahead_cancel(imd); | |
1650 } | |
1651 } | |
1652 | |
1653 static gint image_auto_refresh_cb(gpointer data) | |
1654 { | |
1655 ImageWindow *imd = data; | |
1656 time_t newtime; | |
1657 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1658 if (!imd || !image_get_pixbuf(imd) || |
138 | 1659 imd->il || !imd->image_fd || |
320 | 1660 !options->update_on_time_change) return TRUE; |
9 | 1661 |
138 | 1662 newtime = filetime(imd->image_fd->path); |
9 | 1663 if (newtime > 0 && newtime != imd->mtime) |
1664 { | |
1665 imd->mtime = newtime; | |
1666 image_reload(imd); | |
1667 } | |
1668 | |
1669 return TRUE; | |
1670 } | |
1671 | |
1672 /* image auto refresh on time stamp change, in 1/1000's second, -1 disables */ | |
1673 | |
1674 void image_auto_refresh(ImageWindow *imd, gint interval) | |
1675 { | |
1676 if (!imd) return; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1677 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
9 | 1678 |
1679 if (imd->auto_refresh_id > -1) | |
1680 { | |
1681 g_source_remove(imd->auto_refresh_id); | |
1682 imd->auto_refresh_id = -1; | |
1683 imd->auto_refresh_interval = -1; | |
1684 } | |
1685 | |
1686 if (interval < 0) return; | |
1687 | |
1688 if (interval == 0) interval = IMAGE_AUTO_REFRESH_TIME; | |
1689 | |
1690 imd->auto_refresh_id = g_timeout_add((guint32)interval, image_auto_refresh_cb, imd); | |
1691 imd->auto_refresh_interval = interval; | |
1692 } | |
1693 | |
1694 void image_top_window_set_sync(ImageWindow *imd, gint allow_sync) | |
1695 { | |
1696 imd->top_window_sync = allow_sync; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1697 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1698 g_object_set(G_OBJECT(imd->pr), "window_fit", allow_sync, NULL); |
9 | 1699 } |
1700 | |
1701 void image_background_set_color(ImageWindow *imd, GdkColor *color) | |
1702 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1703 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); |
9 | 1704 } |
1705 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1706 void image_color_profile_set(ImageWindow *imd, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1707 gint input_type, gint screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1708 gint use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1709 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1710 if (!imd) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1711 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1712 if (input_type < 0 || input_type > COLOR_PROFILE_INPUTS || |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1713 screen_type < 0 || screen_type > 1) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1714 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1715 return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1716 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1717 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1718 imd->color_profile_input = input_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1719 imd->color_profile_screen = screen_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1720 imd->color_profile_use_image = use_image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1721 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1722 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1723 gint image_color_profile_get(ImageWindow *imd, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1724 gint *input_type, gint *screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1725 gint *use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1726 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1727 if (!imd) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1728 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1729 if (input_type) *input_type = imd->color_profile_input; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1730 if (screen_type) *screen_type = imd->color_profile_screen; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1731 if (use_image) *use_image = imd->color_profile_use_image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1732 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1733 return TRUE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1734 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1735 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1736 void image_color_profile_set_use(ImageWindow *imd, gint enable) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1737 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1738 if (!imd) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1739 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1740 if (imd->color_profile_enable == enable) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1741 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1742 imd->color_profile_enable = enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1743 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1744 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1745 gint image_color_profile_get_use(ImageWindow *imd) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1746 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1747 if (!imd) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1748 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1749 return imd->color_profile_enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1750 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1751 |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1752 gint image_color_profile_get_from_image(ImageWindow *imd) |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1753 { |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1754 if (!imd) return FALSE; |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1755 |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1756 return imd->color_profile_from_image; |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1757 } |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1758 |
9 | 1759 void image_set_delay_flip(ImageWindow *imd, gint delay) |
1760 { | |
1761 if (!imd || | |
1762 imd->delay_flip == delay) return; | |
1763 | |
1764 imd->delay_flip = delay; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1765 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1766 g_object_set(G_OBJECT(imd->pr), "delay_flip", delay, NULL); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1767 |
9 | 1768 if (!imd->delay_flip && imd->il) |
1769 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1770 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1771 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1772 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1773 if (pr->pixbuf) g_object_unref(pr->pixbuf); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1774 pr->pixbuf = NULL; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1775 |
9 | 1776 image_load_pixbuf_ready(imd); |
1777 } | |
1778 } | |
1779 | |
1780 void image_to_root_window(ImageWindow *imd, gint scaled) | |
1781 { | |
1782 GdkScreen *screen; | |
3 | 1783 GdkWindow *rootwindow; |
1784 GdkPixmap *pixmap; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1785 GdkPixbuf *pixbuf; |
9 | 1786 GdkPixbuf *pb; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1787 gint width, height; |
9 | 1788 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1789 if (!imd) return; |
9 | 1790 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1791 pixbuf = image_get_pixbuf(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1792 if (!pixbuf) return; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1793 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1794 screen = gtk_widget_get_screen(imd->widget); |
9 | 1795 rootwindow = gdk_screen_get_root_window(screen); |
1796 if (gdk_drawable_get_visual(rootwindow) != gdk_visual_get_system()) return; | |
3 | 1797 |
1798 if (scaled) | |
1799 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1800 width = gdk_screen_width(); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1801 height = gdk_screen_height(); |
3 | 1802 } |
1803 else | |
1804 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1805 pixbuf_renderer_get_scaled_size((PixbufRenderer *)imd->pr, &width, &height); |
3 | 1806 } |
1807 | |
334 | 1808 pb = gdk_pixbuf_scale_simple(pixbuf, width, height, (GdkInterpType)options->image.zoom_quality); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1809 |
9 | 1810 gdk_pixbuf_render_pixmap_and_mask (pb, &pixmap, NULL, 128); |
3 | 1811 gdk_window_set_back_pixmap(rootwindow, pixmap, FALSE); |
1812 gdk_window_clear(rootwindow); | |
9 | 1813 g_object_unref(pb); |
1814 g_object_unref(pixmap); | |
3 | 1815 |
1816 gdk_flush(); | |
1817 } | |
1818 | |
127 | 1819 void image_select(ImageWindow *imd, gboolean select) |
1820 { | |
1821 if (imd->has_frame) | |
1822 { | |
151 | 1823 if (select) |
127 | 1824 { |
154 | 1825 gtk_widget_set_state(imd->widget, GTK_STATE_SELECTED); |
151 | 1826 gtk_widget_set_state(imd->pr, GTK_STATE_NORMAL); /* do not propagate */ |
127 | 1827 } |
1828 else | |
154 | 1829 gtk_widget_set_state(imd->widget, GTK_STATE_NORMAL); |
127 | 1830 } |
1831 } | |
1832 | |
1833 | |
174 | 1834 |
1835 void image_set_selectable(ImageWindow *imd, gboolean selectable) | |
1836 { | |
1837 if (imd->has_frame) | |
1838 { | |
1839 if (selectable) | |
1840 { | |
175 | 1841 gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE); |
1842 gtk_container_set_border_width (GTK_CONTAINER (imd->frame), 4); | |
174 | 1843 } |
1844 else | |
1845 { | |
175 | 1846 gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE); |
1847 gtk_container_set_border_width (GTK_CONTAINER (imd->frame), 0); | |
174 | 1848 } |
1849 } | |
1850 } | |
1851 | |
9 | 1852 /* |
1853 *------------------------------------------------------------------- | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1854 * prefs sync |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1855 *------------------------------------------------------------------- |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1856 */ |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1857 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1858 static void image_options_set(ImageWindow *imd) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1859 { |
334 | 1860 g_object_set(G_OBJECT(imd->pr), "zoom_quality", options->image.zoom_quality, |
1861 "zoom_2pass", options->image.zoom_2pass, | |
1862 "zoom_expand", options->image.zoom_to_fit_allow_expand, | |
1863 "dither_quality", options->image.dither_quality, | |
1864 "scroll_reset", options->image.scroll_reset_method, | |
1865 "cache_display", options->image.tile_cache_max, | |
1866 "window_fit", (imd->top_window_sync && options->image.fit_window_to_image), | |
1867 "window_limit", options->image.limit_window_size, | |
1868 "window_limit_value", options->image.max_window_size, | |
1869 "autofit_limit", options->image.limit_autofit_size, | |
1870 "autofit_limit_value", options->image.max_autofit_size, | |
209
ad78ad18523a
configurable frame around image - geeqie_autofit_maxsize.patch by Laurent MONIN
nadvornik
parents:
208
diff
changeset
|
1871 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1872 NULL); |
27
9c24765c2d3a
Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net>
gqview
parents:
26
diff
changeset
|
1873 |
9c24765c2d3a
Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net>
gqview
parents:
26
diff
changeset
|
1874 pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)imd->top_window); |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1875 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1876 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1877 void image_options_sync(void) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1878 { |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1879 GList *work; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1880 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1881 work = image_list; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1882 while (work) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1883 { |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1884 ImageWindow *imd; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1885 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1886 imd = work->data; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1887 work = work->next; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1888 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1889 image_options_set(imd); |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1890 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1891 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1892 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1893 /* |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1894 *------------------------------------------------------------------- |
9 | 1895 * init / destroy |
1896 *------------------------------------------------------------------- | |
1897 */ | |
1898 | |
1899 static void image_free(ImageWindow *imd) | |
1900 { | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1901 image_list = g_list_remove(image_list, imd); |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1902 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1903 image_reset(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1904 |
9 | 1905 image_read_ahead_cancel(imd); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1906 image_post_buffer_set(imd, NULL, NULL, -1); |
9 | 1907 image_auto_refresh(imd, -1); |
1908 | |
138 | 1909 file_data_unref(imd->image_fd); |
9 | 1910 g_free(imd->title); |
1911 g_free(imd->title_right); | |
1912 | |
1913 g_free(imd); | |
1914 } | |
1915 | |
1916 static void image_destroy_cb(GtkObject *widget, gpointer data) | |
1917 { | |
1918 ImageWindow *imd = data; | |
1919 image_free(imd); | |
1920 } | |
1921 | |
151 | 1922 gboolean selectable_frame_expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) |
1923 { | |
1924 gtk_paint_flat_box(widget->style, | |
1925 widget->window, | |
1926 widget->state, | |
1927 GTK_FRAME (widget)->shadow_type, | |
1928 NULL, | |
1929 widget, | |
1930 NULL, | |
174 | 1931 widget->allocation.x + 3, widget->allocation.y + 3, |
1932 widget->allocation.width - 6, widget->allocation.height - 6); | |
151 | 1933 |
1934 | |
1935 return FALSE; | |
1936 } | |
1937 | |
1938 | |
175 | 1939 void image_set_frame(ImageWindow *imd, gboolean frame) |
1940 { | |
1941 frame = !!frame; | |
1942 | |
1943 if (frame == imd->has_frame) return; | |
1944 | |
1945 gtk_widget_hide(imd->pr); | |
1946 | |
1947 if (frame) | |
1948 { | |
1949 imd->frame = gtk_frame_new(NULL); | |
1950 gtk_widget_ref(imd->pr); | |
1951 if (imd->has_frame != -1) gtk_container_remove(GTK_CONTAINER(imd->widget), imd->pr); | |
1952 gtk_container_add(GTK_CONTAINER(imd->frame), imd->pr); | |
1953 gtk_widget_unref(imd->pr); | |
1954 g_signal_connect (G_OBJECT (imd->frame), "expose_event", | |
1955 G_CALLBACK (selectable_frame_expose_cb), NULL); | |
1956 | |
1957 GTK_WIDGET_SET_FLAGS(imd->frame, GTK_CAN_FOCUS); | |
1958 g_signal_connect(G_OBJECT(imd->frame), "focus_in_event", | |
1959 G_CALLBACK(image_focus_in_cb), imd); | |
1960 g_signal_connect(G_OBJECT(imd->frame), "focus_out_event", | |
1961 G_CALLBACK(image_focus_out_cb), imd); | |
1962 | |
1963 g_signal_connect_after(G_OBJECT(imd->frame), "expose_event", | |
1964 G_CALLBACK(image_focus_expose), imd); | |
1965 | |
1966 | |
1967 gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->frame); | |
1968 gtk_widget_show(imd->frame); | |
1969 } | |
1970 else | |
1971 { | |
1972 gtk_widget_ref(imd->pr); | |
1973 if (imd->frame) | |
1974 { | |
1975 gtk_container_remove(GTK_CONTAINER(imd->frame), imd->pr); | |
1976 gtk_widget_destroy(imd->frame); | |
1977 imd->frame = NULL; | |
1978 } | |
1979 gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->pr); | |
1980 gtk_widget_unref(imd->pr); | |
1981 } | |
1982 | |
1983 gtk_widget_show(imd->pr); | |
1984 | |
1985 imd->has_frame = frame; | |
1986 } | |
1987 | |
9 | 1988 ImageWindow *image_new(gint frame) |
1989 { | |
1990 ImageWindow *imd; | |
1991 | |
1992 imd = g_new0(ImageWindow, 1); | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1993 |
9 | 1994 imd->top_window = NULL; |
1995 imd->title = NULL; | |
1996 imd->title_right = NULL; | |
1997 imd->title_show_zoom = FALSE; | |
1998 | |
1999 imd->unknown = TRUE; | |
2000 | |
175 | 2001 imd->has_frame = -1; /* not initialized; for image_set_frame */ |
9 | 2002 imd->top_window_sync = FALSE; |
2003 | |
2004 imd->delay_alter_type = ALTER_NONE; | |
2005 | |
2006 imd->read_ahead_il = NULL; | |
2007 imd->read_ahead_pixbuf = NULL; | |
138 | 2008 imd->read_ahead_fd = NULL; |
9 | 2009 |
2010 imd->completed = FALSE; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
2011 imd->state = IMAGE_STATE_NONE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
2012 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
2013 imd->color_profile_enable = FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
2014 imd->color_profile_input = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
2015 imd->color_profile_screen = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
2016 imd->color_profile_use_image = FALSE; |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
2017 imd->color_profile_from_image = COLOR_PROFILE_NONE; |
9 | 2018 |
2019 imd->auto_refresh_id = -1; | |
2020 imd->auto_refresh_interval = -1; | |
2021 | |
2022 imd->delay_flip = FALSE; | |
2023 | |
2024 imd->func_update = NULL; | |
2025 imd->func_complete = NULL; | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
2026 imd->func_tile_request = NULL; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
2027 imd->func_tile_dispose = NULL; |
9 | 2028 |
2029 imd->func_button = NULL; | |
2030 imd->func_scroll = NULL; | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
2031 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
2032 imd->orientation = 1; |
9 | 2033 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2034 imd->pr = GTK_WIDGET(pixbuf_renderer_new()); |
9 | 2035 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
2036 image_options_set(imd); |
9 | 2037 |
175 | 2038 |
2039 imd->widget = gtk_vbox_new(0, 0); | |
151 | 2040 |
175 | 2041 image_set_frame(imd, frame); |
9 | 2042 |
175 | 2043 image_set_selectable(imd, 0); |
9 | 2044 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2045 g_signal_connect(G_OBJECT(imd->pr), "clicked", |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2046 G_CALLBACK(image_click_cb), imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2047 g_signal_connect(G_OBJECT(imd->pr), "scroll_notify", |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2048 G_CALLBACK(image_scroll_notify_cb), imd); |
9 | 2049 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2050 g_signal_connect(G_OBJECT(imd->pr), "scroll_event", |
9 | 2051 G_CALLBACK(image_scroll_cb), imd); |
2052 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2053 g_signal_connect(G_OBJECT(imd->pr), "destroy", |
9 | 2054 G_CALLBACK(image_destroy_cb), imd); |
2055 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2056 g_signal_connect(G_OBJECT(imd->pr), "zoom", |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2057 G_CALLBACK(image_zoom_cb), imd); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2058 g_signal_connect(G_OBJECT(imd->pr), "render_complete", |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2059 G_CALLBACK(image_render_complete_cb), imd); |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
2060 g_signal_connect(G_OBJECT(imd->pr), "drag", |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
2061 G_CALLBACK(image_drag_cb), imd); |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2062 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
2063 image_list = g_list_append(image_list, imd); |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
2064 |
9 | 2065 return imd; |
2066 } | |
2067 |