Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: libexif/sources/libexif/fuji/mnote-fuji-entry.c

Issue 10535156: Add libexif to deps/third_party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /* mnote-fuji-entry.c
2 *
3 * Copyright (c) 2002 Lutz Mueller <lutz@users.sourceforge.net>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA.
19 */
20
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24
25 #include <config.h>
26
27 #include <libexif/i18n.h>
28
29 #include "mnote-fuji-entry.h"
30
31 #define CF(format,target,v,maxlen) \
32 { \
33 if (format != target) { \
34 snprintf (v, maxlen, \
35 _("Invalid format '%s', " \
36 "expected '%s'."), \
37 exif_format_get_name (format), \
38 exif_format_get_name (target)); \
39 break; \
40 } \
41 }
42
43 #define CC(number,target,v,maxlen) \
44 { \
45 if (number != target) { \
46 snprintf (v, maxlen, \
47 _("Invalid number of components (%i, " \
48 "expected %i)."), (int) number, (int) target); \
49 break; \
50 } \
51 }
52
53 static const struct {
54 ExifTag tag;
55 struct {
56 int index;
57 const char *string;
58 } elem[22];
59 } items[] = {
60 #ifndef NO_VERBOSE_TAG_DATA
61 { MNOTE_FUJI_TAG_SHARPNESS,
62 { {1, N_("Softest")},
63 {2, N_("Soft")},
64 {3, N_("Normal")},
65 {4, N_("Hard")},
66 {5, N_("Hardest")},
67 {0x0082, N_("Medium soft")},
68 {0x0084, N_("Medium hard")},
69 {0x8000, N_("Film simulation mode")},
70 {0xFFFF, N_("Off")},
71 {0, NULL}}},
72 { MNOTE_FUJI_TAG_WHITE_BALANCE,
73 { {0, N_("Auto")},
74 {0x100, N_("Daylight")},
75 {0x200, N_("Cloudy")},
76 {0x300, N_("Daylight fluorescent")},
77 {0x301, N_("Day white fluorescent")},
78 {0x302, N_("White fluorescent")},
79 {0x400, N_("Incandescent")},
80 {0x500, N_("Flash")},
81 {0xF00, N_("Custom")},
82 {0, NULL}}},
83 { MNOTE_FUJI_TAG_COLOR,
84 { {0, N_("Standard")},
85 {0x0080, N_("Medium high")},
86 {0x0100, N_("High")},
87 {0x0180, N_("Medium low")},
88 {0x0200, N_("Original")},
89 {0x0300, N_("Black & white")},
90 {0x8000, N_("Film simulation mode")},
91 {0, NULL}}},
92 { MNOTE_FUJI_TAG_TONE,
93 { {0, N_("Standard")},
94 {0x0080, N_("Medium hard")},
95 {0x0100, N_("Hard")},
96 {0x0180, N_("Medium soft")},
97 {0x0200, N_("Original")},
98 {0x8000, N_("Film simulation mode")},
99 {0, NULL}}},
100 { MNOTE_FUJI_TAG_FLASH_MODE,
101 { {0, N_("Auto")},
102 {1, N_("On")},
103 {2, N_("Off")},
104 {3, N_("Red-eye reduction")},
105 {0, NULL}}},
106 { MNOTE_FUJI_TAG_MACRO,
107 { {0, N_("Off")},
108 {1, N_("On")},
109 {0, NULL}}},
110 { MNOTE_FUJI_TAG_FOCUS_MODE,
111 { {0, N_("Auto")},
112 {1, N_("Manual")},
113 {0, NULL}}},
114 { MNOTE_FUJI_TAG_SLOW_SYNC,
115 { {0, N_("Off")},
116 {1, N_("On")},
117 {0, NULL}}},
118 { MNOTE_FUJI_TAG_PICTURE_MODE,
119 { {0, N_("Auto")},
120 {1, N_("Portrait")},
121 {2, N_("Landscape")},
122 {4, N_("Sports")},
123 {5, N_("Night")},
124 {6, N_("Program AE")},
125 {7, N_("Natural photo")},
126 {8, N_("Vibration reduction")},
127 {0x000A, N_("Sunset")},
128 {0x000B, N_("Museum")},
129 {0x000C, N_("Party")},
130 {0x000D, N_("Flower")},
131 {0x000E, N_("Text")},
132 {0x000F, N_("NP & flash")},
133 {0x0010, N_("Beach")},
134 {0x0011, N_("Snow")},
135 {0x0012, N_("Fireworks")},
136 {0x0013, N_("Underwater")},
137 {0x0100, N_("Aperture priority AE")},
138 {0x0200, N_("Shutter priority AE")},
139 {0x0300, N_("Manual exposure")},
140 {0, NULL}}},
141 { MNOTE_FUJI_TAG_CONT_TAKING,
142 { {0, N_("Off")},
143 {1, N_("On")},
144 {0, NULL}}},
145 { MNOTE_FUJI_TAG_FINEPIX_COLOR,
146 { {0x00, N_("F-Standard")},
147 {0x10, N_("F-Chrome")},
148 {0x30, N_("F-B&W")},
149 {0, NULL}}},
150 { MNOTE_FUJI_TAG_BLUR_CHECK,
151 { {0, N_("No blur")},
152 {1, N_("Blur warning")},
153 {0, NULL}}},
154 { MNOTE_FUJI_TAG_FOCUS_CHECK,
155 { {0, N_("Focus good")},
156 {1, N_("Out of focus")},
157 {0, NULL}}},
158 { MNOTE_FUJI_TAG_AUTO_EXPOSURE_CHECK,
159 { {0, N_("AE good")},
160 {1, N_("Over exposed")},
161 {0, NULL}}},
162 { MNOTE_FUJI_TAG_DYNAMIC_RANGE,
163 { {1, N_("Standard")},
164 {3, N_("Wide")},
165 {0, NULL}}},
166 { MNOTE_FUJI_TAG_FILM_MODE,
167 { {0, N_("F0/Standard")},
168 {0x0100, N_("F1/Studio portrait")},
169 {0x0110, N_("F1a/Professional portrait")},
170 {0x0120, N_("F1b/Professional portrait")},
171 {0x0130, N_("F1c/Professional portrait")},
172 {0x0200, N_("F2/Fujichrome")},
173 {0x0300, N_("F3/Studio portrait Ex")},
174 {0x0400, N_("F4/Velvia")},
175 {0, NULL}}},
176 { MNOTE_FUJI_TAG_DYNAMIC_RANGE_SETTING,
177 { {0, N_("Auto (100-400%)")},
178 {1, N_("RAW")},
179 {0x0100, N_("Standard (100%)")},
180 {0x0200, N_("Wide1 (230%)")},
181 {0x0201, N_("Wide2 (400%)")},
182 {0x8000, N_("Film simulation mode")},
183 {0, NULL}}},
184 #endif
185 {0, {{0, NULL}}}
186 };
187
188
189 char *
190 mnote_fuji_entry_get_value (MnoteFujiEntry *entry,
191 char *val, unsigned int maxlen)
192 {
193 ExifLong vl;
194 ExifSLong vsl;
195 ExifShort vs, vs2;
196 ExifRational vr;
197 ExifSRational vsr;
198 int i, j;
199
200 if (!entry) return (NULL);
201
202 memset (val, 0, maxlen);
203 maxlen--;
204
205 switch (entry->tag) {
206 case MNOTE_FUJI_TAG_VERSION:
207 CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen);
208 CC (entry->components, 4, val, maxlen);
209 memcpy (val, entry->data, MIN(maxlen, entry->size));
210 break;
211 case MNOTE_FUJI_TAG_SHARPNESS:
212 case MNOTE_FUJI_TAG_WHITE_BALANCE:
213 case MNOTE_FUJI_TAG_COLOR:
214 case MNOTE_FUJI_TAG_TONE:
215 case MNOTE_FUJI_TAG_FLASH_MODE:
216 case MNOTE_FUJI_TAG_MACRO:
217 case MNOTE_FUJI_TAG_FOCUS_MODE:
218 case MNOTE_FUJI_TAG_SLOW_SYNC:
219 case MNOTE_FUJI_TAG_PICTURE_MODE:
220 case MNOTE_FUJI_TAG_CONT_TAKING:
221 case MNOTE_FUJI_TAG_FINEPIX_COLOR:
222 case MNOTE_FUJI_TAG_BLUR_CHECK:
223 case MNOTE_FUJI_TAG_FOCUS_CHECK:
224 case MNOTE_FUJI_TAG_AUTO_EXPOSURE_CHECK:
225 case MNOTE_FUJI_TAG_DYNAMIC_RANGE:
226 case MNOTE_FUJI_TAG_FILM_MODE:
227 case MNOTE_FUJI_TAG_DYNAMIC_RANGE_SETTING:
228 CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
229 CC (entry->components, 1, val, maxlen);
230 vs = exif_get_short (entry->data, entry->order);
231
232 /* search the tag */
233 for (i = 0; (items[i].tag && items[i].tag != entry->tag); i++);
234 if (!items[i].tag) {
235 snprintf (val, maxlen,
236 _("Internal error (unknown value %i)"), vs);
237 break;
238 }
239
240 /* find the value */
241 for (j = 0; items[i].elem[j].string &&
242 (items[i].elem[j].index < vs); j++);
243 if (items[i].elem[j].index != vs) {
244 snprintf (val, maxlen,
245 _("Internal error (unknown value %i)"), vs);
246 break;
247 }
248 strncpy (val, _(items[i].elem[j].string), maxlen);
249 break;
250 case MNOTE_FUJI_TAG_FOCUS_POINT:
251 CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
252 CC (entry->components, 2, val, maxlen);
253 vs = exif_get_short (entry->data, entry->order);
254 vs2 = exif_get_short (entry->data+2, entry->order);
255 snprintf (val, maxlen, "%i, %i", vs, vs2);
256 break;
257 case MNOTE_FUJI_TAG_MIN_FOCAL_LENGTH:
258 case MNOTE_FUJI_TAG_MAX_FOCAL_LENGTH:
259 CF (entry->format, EXIF_FORMAT_RATIONAL, val, maxlen);
260 CC (entry->components, 1, val, maxlen);
261 vr = exif_get_rational (entry->data, entry->order);
262 if (!vr.denominator) break;
263 snprintf (val, maxlen, _("%2.2f mm"), (double) vr.numerator /
264 vr.denominator);
265 break;
266
267 default:
268 switch (entry->format) {
269 case EXIF_FORMAT_ASCII:
270 strncpy (val, (char *)entry->data, MIN(maxlen, entry->size));
271 break;
272 case EXIF_FORMAT_SHORT:
273 vs = exif_get_short (entry->data, entry->order);
274 snprintf (val, maxlen, "%i", vs);
275 break;
276 case EXIF_FORMAT_LONG:
277 vl = exif_get_long (entry->data, entry->order);
278 snprintf (val, maxlen, "%lu", (long unsigned) vl);
279 break;
280 case EXIF_FORMAT_SLONG:
281 vsl = exif_get_slong (entry->data, entry->order);
282 snprintf (val, maxlen, "%li", (long int) vsl);
283 break;
284 case EXIF_FORMAT_RATIONAL:
285 vr = exif_get_rational (entry->data, entry->order);
286 if (!vr.denominator) break;
287 snprintf (val, maxlen, "%2.4f", (double) vr.numerator /
288 vr.denominator);
289 break;
290 case EXIF_FORMAT_SRATIONAL:
291 vsr = exif_get_srational (entry->data, entry->order);
292 if (!vsr.denominator) break;
293 snprintf (val, maxlen, "%2.4f", (double) vsr.numerator /
294 vsr.denominator);
295 break;
296 case EXIF_FORMAT_UNDEFINED:
297 default:
298 snprintf (val, maxlen, _("%i bytes unknown data"),
299 entry->size);
300 break;
301 }
302 break;
303 }
304
305 return (val);
306 }
OLDNEW
« no previous file with comments | « libexif/sources/libexif/fuji/mnote-fuji-entry.h ('k') | libexif/sources/libexif/fuji/mnote-fuji-tag.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698