1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
/* mnote-pentax-entry.c
*
* Copyright (c) 2002 Lutz Mueller <lutz@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include "mnote-pentax-entry.h"
#include <libexif/i18n.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libexif/exif-format.h>
#include <libexif/exif-utils.h>
#include <libexif/exif-entry.h>
#define CF(format,target,v,maxlen) \
{ \
if (format != target) { \
snprintf (v, maxlen, \
_("Invalid format '%s', " \
"expected '%s'."), \
exif_format_get_name (format), \
exif_format_get_name (target)); \
break; \
} \
}
#define CC(number,target,v,maxlen) \
{ \
if (number != target) { \
snprintf (v, maxlen, \
_("Invalid number of components (%i, " \
"expected %i)."), (int) number, (int) target); \
break; \
} \
}
#define CC2(number,t1,t2,v,maxlen) \
{ \
if ((number != t1) && (number != t2)) { \
snprintf (v, maxlen, \
_("Invalid number of components (%i, " \
"expected %i or %i)."), (int) number, \
(int) t1, (int) t2); \
break; \
} \
}
static const struct {
ExifTag tag;
struct {
int index;
const char *string;
} elem[33];
} items[] = {
#ifndef NO_VERBOSE_TAG_DATA
{ MNOTE_PENTAX_TAG_MODE,
{ {0, N_("Auto")},
{1, N_("Night-scene")},
{2, N_("Manual")},
{4, N_("Multi-exposure")},
{0, NULL}}},
{ MNOTE_PENTAX_TAG_QUALITY,
{ {0, N_("Good")},
{1, N_("Better")},
{2, N_("Best")},{0,NULL}}},
{ MNOTE_PENTAX_TAG_FOCUS,
{ {2, N_("Custom")},
{3, N_("Auto")},
{0, NULL}}},
{ MNOTE_PENTAX_TAG_FLASH,
{ {1, N_("Auto")},
{2, N_("Flash on")},
{4, N_("Flash off")},
{6, N_("Red-eye Reduction")},
{0, NULL}}},
{ MNOTE_PENTAX_TAG_WHITE_BALANCE,
{ {0, N_("Auto")},
{1, N_("Daylight")},
{2, N_("Shade")},
{3, N_("Tungsten")},
{4, N_("Fluorescent")},
{5, N_("Manual")},
{0, NULL}}},
{ MNOTE_PENTAX_TAG_SHARPNESS,
{ {0, N_("Normal")},
{1, N_("Soft")},
{2, N_("Hard")},
{0, NULL}}},
{ MNOTE_PENTAX_TAG_CONTRAST,
{ {0, N_("Normal")},
{1, N_("Low")},
{2, N_("High")},
{0, NULL}}},
{ MNOTE_PENTAX_TAG_SATURATION,
{ {0, N_("Normal")},
{1, N_("Low")},
{2, N_("High")},
{0, NULL}}},
{ MNOTE_PENTAX_TAG_ISO_SPEED,
{ {10, N_("100")},
{16, N_("200")},
{100, N_("100")},
{200, N_("200")},
{ 0, NULL}}},
{ MNOTE_PENTAX_TAG_COLOR,
{ {1, N_("Full")},
{2, N_("Black & White")},
{3, N_("Sepia")},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_MODE,
{ {0, N_("Auto")},
{1, N_("Night-scene")},
{2, N_("Manual")},
{4, N_("Multi-exposure")},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_QUALITY,
{ {0, N_("Good")},
{1, N_("Better")},
{2, N_("Best")},
{3, N_("TIFF")},
{4, N_("RAW")},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_IMAGE_SIZE,
{ {0, "640x480"},
{1, N_("Full")},
{2, "1024x768"},
{3, "1280x960"},
{4, "1600x1200"},
{5, "2048x1536"},
{8, N_("2560x1920 or 2304x1728")},
{9, "3072x2304"},
{10, "3264x2448"},
{19, "320x240"},
{20, "2288x1712"},
{21, "2592x1944"},
{22, N_("2304x1728 or 2592x1944")},
{23, "3056x2296"},
{25, N_("2816x2212 or 2816x2112")},
{27, "3648x2736"},
{36, "3008x2008"},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_PICTURE_MODE,
{ {0, N_("Program")},
{2, N_("Program AE")},
{3, N_("Manual")},
{5, N_("Portrait")},
{6, N_("Landscape")},
{8, N_("Sport")},
{9, N_("Night Scene")},
{11, N_("Soft")},
{12, N_("Surf & Snow")},
{13, N_("Sunset or Candlelight")},
{14, N_("Autumn")},
{15, N_("Macro")},
{17, N_("Fireworks")},
{18, N_("Text")},
{19, N_("Panorama")},
{30, N_("Self Portrait")},
{31, N_("Illustrations")},
{33, N_("Digital Filter")},
{37, N_("Museum")},
{38, N_("Food")},
{40, N_("Green Mode")},
{49, N_("Light Pet")},
{50, N_("Dark Pet")},
{51, N_("Medium Pet")},
{53, N_("Underwater")},
{54, N_("Candlelight")},
{55, N_("Natural Skin Tone")},
{56, N_("Synchro Sound Record")},
{58, N_("Frame Composite")},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_FLASH_MODE,
{ {0x0000, N_("Auto, Did not fire")},
{0x0001, N_("Off")},
{0x0003, N_("Auto, Did not fire, Red-eye reduction")},
{0x0100, N_("Auto, Fired")},
{0x0102, N_("On")},
{0x0103, N_("Auto, Fired, Red-eye reduction")},
{0x0104, N_("On, Red-eye reduction")},
{0x0105, N_("On, Wireless")},
{0x0108, N_("On, Soft")},
{0x0109, N_("On, Slow-sync")},
{0x010a, N_("On, Slow-sync, Red-eye reduction")},
{0x010b, N_("On, Trailing-curtain Sync")},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_FOCUS_MODE,
{ {0, N_("Normal")},
{1, N_("Macro")},
{2, N_("Infinity")},
{3, N_("Manual")},
{5, N_("Pan Focus")},
{16, N_("AF-S")},
{17, N_("AF-C")},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_AFPOINT_SELECTED,
{ {1, N_("Upper-left")},
{2, N_("Top")},
{3, N_("Upper-right")},
{4, N_("Left")},
{5, N_("Mid-left")},
{6, N_("Center")},
{7, N_("Mid-right")},
{8, N_("Right")},
{9, N_("Lower-left")},
{10, N_("Bottom")},
{11, N_("Lower-right")},
{0xfffe, N_("Fixed Center")},
{0xffff, N_("Auto")},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_AUTO_AFPOINT,
{ {0, N_("Multiple")},
{1, N_("Top-left")},
{2, N_("Top-center")},
{3, N_("Top-right")},
{4, N_("Left")},
{5, N_("Center")},
{6, N_("Right")},
{7, N_("Bottom-left")},
{8, N_("Bottom-center")},
{9, N_("Bottom-right")},
{0xffff, N_("None")},
{0, NULL}}},
{ MNOTE_PENTAX2_TAG_WHITE_BALANCE,
{ {0, N_("Auto")},
{1, N_("Daylight")},
{2, N_("Shade")},
{3, N_("Fluorescent")},
{4, N_("Tungsten")},
{5, N_("Manual")},
{6, N_("Daylight Fluorescent")},
{7, N_("Daywhite Fluorescent")},
{8, N_("White Fluorescent")},
{9, N_("Flash")},
{10, N_("Cloudy")},
{0xfffe, N_("Unknown")},
{0xffff, N_("User Selected")},
{0, NULL}}},
{MNOTE_CASIO2_TAG_BESTSHOT_MODE,
{ {0, N_("Off")},
{1, N_("On")},
{0, NULL}}},
#endif
{0, {{0, NULL}}}
};
/* Two-component values */
static const struct {
ExifTag tag;
struct {
int index1, index2;
const char *string;
} elem[39];
} items2[] = {
#ifndef NO_VERBOSE_TAG_DATA
{ MNOTE_PENTAX2_TAG_IMAGE_SIZE,
{ {0, 0, "2304x1728"},
{4, 0, "1600x1200"},
{5, 0, "2048x1536"},
{8, 0, "2560x1920"},
{34, 0, "1536x1024"},
{36, 0, N_("3008x2008 or 3040x2024")},
{37, 0, "3008x2000"},
{35, 1, "2400x1600"},
{32, 2, "960x480"},
{33, 2, "1152x768"},
{34, 2, "1536x1024"},
{0, 0, NULL}}},
{ MNOTE_PENTAX2_TAG_PICTURE_MODE,
{ {0, 0, N_("Auto")},
{5, 0, N_("Portrait")},
{53, 0, N_("Underwater")},
{255, 0, N_("Digital Filter?")},
{5, 1, N_("Portrait")},
{9, 1, N_("Night Scene")},
{13, 1, N_("Candlelight")},
{15, 1, N_("Macro")},
{53, 1, N_("Underwater")},
{0, 2, N_("Program AE")},
{5, 2, N_("Portrait")},
{6, 2, N_("Landscape")},
{0, 0, NULL}}},
#endif
{0, {{0, 0, NULL}}}
};
char *
mnote_pentax_entry_get_value (MnotePentaxEntry *entry,
char *val, unsigned int maxlen)
{
ExifLong vl;
ExifShort vs, vs2;
int i = 0, j = 0;
if (!entry) return (NULL);
memset (val, 0, maxlen);
maxlen--;
switch (entry->tag) {
case MNOTE_PENTAX_TAG_MODE:
case MNOTE_PENTAX_TAG_QUALITY:
case MNOTE_PENTAX_TAG_FOCUS:
case MNOTE_PENTAX_TAG_FLASH:
case MNOTE_PENTAX_TAG_WHITE_BALANCE:
case MNOTE_PENTAX_TAG_SHARPNESS:
case MNOTE_PENTAX_TAG_CONTRAST:
case MNOTE_PENTAX_TAG_SATURATION:
case MNOTE_PENTAX_TAG_ISO_SPEED:
case MNOTE_PENTAX_TAG_COLOR:
case MNOTE_PENTAX2_TAG_MODE:
case MNOTE_PENTAX2_TAG_QUALITY:
case MNOTE_PENTAX2_TAG_FLASH_MODE:
case MNOTE_PENTAX2_TAG_FOCUS_MODE:
case MNOTE_PENTAX2_TAG_AFPOINT_SELECTED:
case MNOTE_PENTAX2_TAG_AUTO_AFPOINT:
case MNOTE_PENTAX2_TAG_WHITE_BALANCE:
case MNOTE_PENTAX2_TAG_PICTURE_MODE:
case MNOTE_PENTAX2_TAG_IMAGE_SIZE:
case MNOTE_CASIO2_TAG_BESTSHOT_MODE:
CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
CC2 (entry->components, 1, 2, val, maxlen);
if (entry->components == 1) {
vs = exif_get_short (entry->data, entry->order);
/* search the tag */
for (i = 0; (items[i].tag && items[i].tag != entry->tag); i++);
if (!items[i].tag) {
snprintf (val, maxlen,
_("Internal error (unknown value %i)"), vs);
break;
}
/* find the value */
for (j = 0; items[i].elem[j].string &&
(items[i].elem[j].index < vs); j++);
if (items[i].elem[j].index != vs) {
snprintf (val, maxlen,
_("Internal error (unknown value %i)"), vs);
break;
}
strncpy (val, _(items[i].elem[j].string), maxlen);
} else {
/* Two-component values */
CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
CC2 (entry->components, 1, 2, val, maxlen);
vs = exif_get_short (entry->data, entry->order);
vs2 = exif_get_short (entry->data+2, entry->order) << 16;
/* search the tag */
for (i = 0; (items2[i].tag && items2[i].tag != entry->tag); i++);
if (!items2[i].tag) {
snprintf (val, maxlen,
_("Internal error (unknown value %i %i)"), vs, vs2);
break;
}
/* find the value */
for (j = 0; items2[i].elem[j].string && ((items2[i].elem[j].index2 < vs2)
|| ((items2[i].elem[j].index2 == vs2) && (items2[i].elem[j].index1 < vs))); j++);
if ((items2[i].elem[j].index1 != vs) || (items2[i].elem[j].index2 != vs2)) {
snprintf (val, maxlen,
_("Internal error (unknown value %i %i)"), vs, vs2);
break;
}
strncpy (val, _(items2[i].elem[j].string), maxlen);
}
break;
case MNOTE_PENTAX_TAG_ZOOM:
CF (entry->format, EXIF_FORMAT_LONG, val, maxlen);
CC (entry->components, 1, val, maxlen);
vl = exif_get_long (entry->data, entry->order);
snprintf (val, maxlen, "%li", (long int) vl);
break;
case MNOTE_PENTAX_TAG_PRINTIM:
CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen);
CC (entry->components, 124, val, maxlen);
snprintf (val, maxlen, _("%i bytes unknown data"),
entry->size);
break;
case MNOTE_PENTAX_TAG_TZ_CITY:
CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen);
CC (entry->components, 4, val, maxlen);
strncpy (val, (char*)entry->data, MIN(maxlen, entry->size));
break;
case MNOTE_PENTAX_TAG_TZ_DST:
CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen);
CC (entry->components, 4, val, maxlen);
strncpy (val, (char*)entry->data, MIN(maxlen, entry->size));
break;
default:
switch (entry->format) {
case EXIF_FORMAT_ASCII:
strncpy (val, (char *)entry->data, MIN(maxlen, entry->size));
break;
case EXIF_FORMAT_SHORT:
vs = exif_get_short (entry->data, entry->order);
snprintf (val, maxlen, "%i", vs);
break;
case EXIF_FORMAT_LONG:
vl = exif_get_long (entry->data, entry->order);
snprintf (val, maxlen, "%li", (long int) vl);
break;
case EXIF_FORMAT_UNDEFINED:
default:
snprintf (val, maxlen, _("%i bytes unknown data"),
entry->size);
break;
}
break;
}
return (val);
}
|