EXIF library (libexif) Internals  0.6.24
mnote-fuji-entry.c
Go to the documentation of this file.
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 {
55  struct {
56  int index;
57  const char *string;
58  } elem[22];
59 } items[] = {
60 #ifndef NO_VERBOSE_TAG_DATA
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}}},
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}}},
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}}},
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}}},
101  { {0, N_("Auto")},
102  {1, N_("On")},
103  {2, N_("Off")},
104  {3, N_("Red-eye reduction")},
105  {0, NULL}}},
107  { {0, N_("Off")},
108  {1, N_("On")},
109  {0, NULL}}},
111  { {0, N_("Auto")},
112  {1, N_("Manual")},
113  {0, NULL}}},
115  { {0, N_("Off")},
116  {1, N_("On")},
117  {0, NULL}}},
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}}},
142  { {0, N_("Off")},
143  {1, N_("On")},
144  {0, NULL}}},
146  { {0x00, N_("F-Standard")},
147  {0x10, N_("F-Chrome")},
148  {0x30, N_("F-B&W")},
149  {0, NULL}}},
151  { {0, N_("No blur")},
152  {1, N_("Blur warning")},
153  {0, NULL}}},
155  { {0, N_("Focus good")},
156  {1, N_("Out of focus")},
157  {0, NULL}}},
159  { {0, N_("AE good")},
160  {1, N_("Over exposed")},
161  {0, NULL}}},
163  { {1, N_("Standard")},
164  {3, N_("Wide")},
165  {0, NULL}}},
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}}},
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 *
191  char *val, unsigned int maxlen)
192 {
193  ExifLong vl;
194  ExifSLong vsl;
195  ExifShort vs, vs2;
196  ExifSShort vss;
197  ExifRational vr;
198  ExifSRational vsr;
199  int i, j;
200 
201  if (!entry) return (NULL);
202 
203  memset (val, 0, maxlen);
204  maxlen--;
205 
206  switch (entry->tag) {
208  CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen);
209  CC (entry->components, 4, val, maxlen);
210  memcpy (val, entry->data, MIN(maxlen, entry->size));
211  break;
215  case MNOTE_FUJI_TAG_TONE:
229  CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
230  CC (entry->components, 1, val, maxlen);
231  vs = exif_get_short (entry->data, entry->order);
232 
233  /* search the tag */
234  for (i = 0; (items[i].tag && items[i].tag != entry->tag); i++);
235  if (!items[i].tag) {
236  snprintf (val, maxlen,
237  _("Internal error (unknown value %i)"), vs);
238  break;
239  }
240 
241  /* find the value */
242  for (j = 0; items[i].elem[j].string &&
243  (items[i].elem[j].index < vs); j++);
244  if (items[i].elem[j].index != vs) {
245  snprintf (val, maxlen,
246  _("Internal error (unknown value %i)"), vs);
247  break;
248  }
249  strncpy (val, _(items[i].elem[j].string), maxlen);
250  break;
252  CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
253  CC (entry->components, 2, val, maxlen);
254  vs = exif_get_short (entry->data, entry->order);
255  vs2 = exif_get_short (entry->data+2, entry->order);
256  snprintf (val, maxlen, "%i, %i", vs, vs2);
257  break;
260  CF (entry->format, EXIF_FORMAT_RATIONAL, val, maxlen);
261  CC (entry->components, 1, val, maxlen);
262  vr = exif_get_rational (entry->data, entry->order);
263  if (!vr.denominator) break;
264  snprintf (val, maxlen, _("%2.2f mm"), (double) vr.numerator /
265  vr.denominator);
266  break;
267 
268  default:
269  switch (entry->format) {
270  case EXIF_FORMAT_ASCII:
271  strncpy (val, (char *)entry->data, MIN(maxlen, entry->size));
272  break;
273  case EXIF_FORMAT_SHORT:
274  vs = exif_get_short (entry->data, entry->order);
275  snprintf (val, maxlen, "%hu", vs);
276  break;
277  case EXIF_FORMAT_SSHORT:
278  vss = exif_get_sshort (entry->data, entry->order);
279  snprintf (val, maxlen, "%hi", vss);
280  break;
281  case EXIF_FORMAT_LONG:
282  vl = exif_get_long (entry->data, entry->order);
283  snprintf (val, maxlen, "%lu", (long unsigned) vl);
284  break;
285  case EXIF_FORMAT_SLONG:
286  vsl = exif_get_slong (entry->data, entry->order);
287  snprintf (val, maxlen, "%li", (long int) vsl);
288  break;
290  vr = exif_get_rational (entry->data, entry->order);
291  if (!vr.denominator) break;
292  snprintf (val, maxlen, "%2.4f", (double) vr.numerator /
293  vr.denominator);
294  break;
296  vsr = exif_get_srational (entry->data, entry->order);
297  if (!vsr.denominator) break;
298  snprintf (val, maxlen, "%2.4f", (double) vsr.numerator /
299  vsr.denominator);
300  break;
302  default:
303  snprintf (val, maxlen, _("%i bytes unknown data"),
304  entry->size);
305  break;
306  }
307  break;
308  }
309 
310  return (val);
311 }
@ EXIF_FORMAT_SLONG
Definition: exif-format.h:41
@ EXIF_FORMAT_RATIONAL
Definition: exif-format.h:37
@ EXIF_FORMAT_SRATIONAL
Definition: exif-format.h:42
@ EXIF_FORMAT_LONG
Definition: exif-format.h:36
@ EXIF_FORMAT_UNDEFINED
Definition: exif-format.h:39
@ EXIF_FORMAT_SHORT
Definition: exif-format.h:35
@ EXIF_FORMAT_SSHORT
Definition: exif-format.h:40
@ EXIF_FORMAT_ASCII
Definition: exif-format.h:34
ExifRational exif_get_rational(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifRational value from memory.
Definition: exif-utils.c:188
ExifLong exif_get_long(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifLong value from memory.
Definition: exif-utils.c:165
ExifShort exif_get_short(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifShort value from memory.
Definition: exif-utils.c:102
ExifSLong exif_get_slong(const unsigned char *b, ExifByteOrder order)
Retrieve an ExifSLong value from memory.
Definition: exif-utils.c:130
ExifSShort exif_get_sshort(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifSShort value from memory.
Definition: exif-utils.c:87
ExifSRational exif_get_srational(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifSRational value from memory.
Definition: exif-utils.c:177
uint32_t ExifLong
EXIF Unsigned Long data type.
Definition: exif-utils.h:54
int32_t ExifSLong
EXIF Signed Long data type.
Definition: exif-utils.h:57
uint16_t ExifShort
EXIF Unsigned Short data type.
Definition: exif-utils.h:48
#define MIN(a, b)
Definition: exif-utils.h:180
int16_t ExifSShort
EXIF Signed Short data type.
Definition: exif-utils.h:51
#define _(String)
Definition: i18n.h:48
#define N_(String)
Definition: i18n.h:49
#define CC(number, target, v, maxlen)
char * mnote_fuji_entry_get_value(MnoteFujiEntry *entry, char *val, unsigned int maxlen)
struct @10::@11 elem[22]
int index
MnoteFujiTag tag
#define CF(format, target, v, maxlen)
static const struct @10 items[]
const char * string
enum _MnoteFujiTag MnoteFujiTag
@ MNOTE_FUJI_TAG_MAX_FOCAL_LENGTH
@ MNOTE_FUJI_TAG_DYNAMIC_RANGE_SETTING
@ MNOTE_FUJI_TAG_FLASH_MODE
@ MNOTE_FUJI_TAG_WHITE_BALANCE
@ MNOTE_FUJI_TAG_SHARPNESS
@ MNOTE_FUJI_TAG_CONT_TAKING
@ MNOTE_FUJI_TAG_BLUR_CHECK
@ MNOTE_FUJI_TAG_SLOW_SYNC
@ MNOTE_FUJI_TAG_PICTURE_MODE
@ MNOTE_FUJI_TAG_TONE
@ MNOTE_FUJI_TAG_FINEPIX_COLOR
@ MNOTE_FUJI_TAG_AUTO_EXPOSURE_CHECK
@ MNOTE_FUJI_TAG_FOCUS_POINT
@ MNOTE_FUJI_TAG_COLOR
@ MNOTE_FUJI_TAG_MACRO
@ MNOTE_FUJI_TAG_DYNAMIC_RANGE
@ MNOTE_FUJI_TAG_MIN_FOCAL_LENGTH
@ MNOTE_FUJI_TAG_VERSION
@ MNOTE_FUJI_TAG_FILM_MODE
@ MNOTE_FUJI_TAG_FOCUS_MODE
@ MNOTE_FUJI_TAG_FOCUS_CHECK
EXIF Unsigned Rational data type.
Definition: exif-utils.h:60
ExifLong denominator
Definition: exif-utils.h:60
ExifLong numerator
Definition: exif-utils.h:60
EXIF Signed Rational data type.
Definition: exif-utils.h:65
ExifSLong numerator
Definition: exif-utils.h:65
ExifSLong denominator
Definition: exif-utils.h:65
MnoteFujiTag tag
unsigned char * data
ExifByteOrder order
unsigned int size
unsigned long components

libexif Generated by doxygen