Debian Codegraph @

src/com/drew/metadata/exif/makernotes/OlympusCameraSettingsMakernoteDescriptor.java

raw symbols SCIP
1 /*
2 * Copyright 2002-2015 Drew Noakes
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * More information about this project is available at:
17 *
18 * https://drewnoakes.com/code/exif/
19 * https://github.com/drewnoakes/metadata-extractor
20 */
21 package com.drew.metadata.exif.makernotes;
22
23 import com.drew.lang.Rational;
24 import com.drew.lang.annotations.NotNull;
25 import com.drew.lang.annotations.Nullable;
26 import com.drew.metadata.TagDescriptor;
27
28 import java.text.DecimalFormat;
29 import java.util.HashMap;
30
31 import static com.drew.metadata.exif.makernotes.OlympusCameraSettingsMakernoteDirectory.*;
32
33 /**
34 * Provides human-readable String representations of tag values stored in a {@link OlympusCameraSettingsMakernoteDirectory}.
35 * <p>
36 * Some Description functions and the Extender and Lens types lists converted from Exiftool version 10.10 created by Phil Harvey
37 * http://www.sno.phy.queensu.ca/~phil/exiftool/
38 * lib\Image\ExifTool\Olympus.pm
39 *
40 * @author Kevin Mott https://github.com/kwhopper
41 * @author Drew Noakes https://drewnoakes.com
42 */
43 @SuppressWarnings("WeakerAccess")
44 public class OlympusCameraSettingsMakernoteDescriptor extends TagDescriptor<OlympusCameraSettingsMakernoteDirectory>
45 {
46 public OlympusCameraSettingsMakernoteDescriptor(@NotNull OlympusCameraSettingsMakernoteDirectory directory)
47 {
48 super(directory);
49 }
50
51 @Override
52 @Nullable
53 public String getDescription(int tagType)
54 {
55 switch (tagType) {
56 case TagCameraSettingsVersion:
57 return getCameraSettingsVersionDescription();
58 case TagPreviewImageValid:
59 return getPreviewImageValidDescription();
60
61 case TagExposureMode:
62 return getExposureModeDescription();
63 case TagAeLock:
64 return getAeLockDescription();
65 case TagMeteringMode:
66 return getMeteringModeDescription();
67 case TagExposureShift:
68 return getExposureShiftDescription();
69 case TagNdFilter:
70 return getNdFilterDescription();
71
72 case TagMacroMode:
73 return getMacroModeDescription();
74 case TagFocusMode:
75 return getFocusModeDescription();
76 case TagFocusProcess:
77 return getFocusProcessDescription();
78 case TagAfSearch:
79 return getAfSearchDescription();
80 case TagAfAreas:
81 return getAfAreasDescription();
82 case TagAfPointSelected:
83 return getAfPointSelectedDescription();
84 case TagAfFineTune:
85 return getAfFineTuneDescription();
86
87 case TagFlashMode:
88 return getFlashModeDescription();
89 case TagFlashRemoteControl:
90 return getFlashRemoteControlDescription();
91 case TagFlashControlMode:
92 return getFlashControlModeDescription();
93 case TagFlashIntensity:
94 return getFlashIntensityDescription();
95 case TagManualFlashStrength:
96 return getManualFlashStrengthDescription();
97
98 case TagWhiteBalance2:
99 return getWhiteBalance2Description();
100 case TagWhiteBalanceTemperature:
101 return getWhiteBalanceTemperatureDescription();
102 case TagCustomSaturation:
103 return getCustomSaturationDescription();
104 case TagModifiedSaturation:
105 return getModifiedSaturationDescription();
106 case TagContrastSetting:
107 return getContrastSettingDescription();
108 case TagSharpnessSetting:
109 return getSharpnessSettingDescription();
110 case TagColorSpace:
111 return getColorSpaceDescription();
112 case TagSceneMode:
113 return getSceneModeDescription();
114 case TagNoiseReduction:
115 return getNoiseReductionDescription();
116 case TagDistortionCorrection:
117 return getDistortionCorrectionDescription();
118 case TagShadingCompensation:
119 return getShadingCompensationDescription();
120 case TagGradation:
121 return getGradationDescription();
122 case TagPictureMode:
123 return getPictureModeDescription();
124 case TagPictureModeSaturation:
125 return getPictureModeSaturationDescription();
126 case TagPictureModeContrast:
127 return getPictureModeContrastDescription();
128 case TagPictureModeSharpness:
129 return getPictureModeSharpnessDescription();
130 case TagPictureModeBWFilter:
131 return getPictureModeBWFilterDescription();
132 case TagPictureModeTone:
133 return getPictureModeToneDescription();
134 case TagNoiseFilter:
135 return getNoiseFilterDescription();
136 case TagArtFilter:
137 return getArtFilterDescription();
138 case TagMagicFilter:
139 return getMagicFilterDescription();
140 case TagPictureModeEffect:
141 return getPictureModeEffectDescription();
142 case TagToneLevel:
143 return getToneLevelDescription();
144 case TagArtFilterEffect:
145 return getArtFilterEffectDescription();
146 case TagColorCreatorEffect:
147 return getColorCreatorEffectDescription();
148
149 case TagDriveMode:
150 return getDriveModeDescription();
151 case TagPanoramaMode:
152 return getPanoramaModeDescription();
153 case TagImageQuality2:
154 return getImageQuality2Description();
155 case TagImageStabilization:
156 return getImageStabilizationDescription();
157
158 case TagStackedImage:
159 return getStackedImageDescription();
160
161 case TagManometerPressure:
162 return getManometerPressureDescription();
163 case TagManometerReading:
164 return getManometerReadingDescription();
165 case TagExtendedWBDetect:
166 return getExtendedWBDetectDescription();
167 case TagRollAngle:
168 return getRollAngleDescription();
169 case TagPitchAngle:
170 return getPitchAngleDescription();
171 case TagDateTimeUtc:
172 return getDateTimeUTCDescription();
173
174 default:
175 return super.getDescription(tagType);
176 }
177 }
178
179 @Nullable
180 public String getCameraSettingsVersionDescription()
181 {
182 return getVersionBytesDescription(TagCameraSettingsVersion, 4);
183 }
184
185 @Nullable
186 public String getPreviewImageValidDescription()
187 {
188 return getIndexedDescription(TagPreviewImageValid,
189 "No", "Yes");
190 }
191
192 @Nullable
193 public String getExposureModeDescription()
194 {
195 return getIndexedDescription(TagExposureMode, 1,
196 "Manual", "Program", "Aperture-priority AE", "Shutter speed priority", "Program-shift");
197 }
198
199 @Nullable
200 public String getAeLockDescription()
201 {
202 return getIndexedDescription(TagAeLock,
203 "Off", "On");
204 }
205
206 @Nullable
207 public String getMeteringModeDescription()
208 {
209 Integer value = _directory.getInteger(TagMeteringMode);
210 if (value == null)
211 return null;
212
213 switch (value) {
214 case 2:
215 return "Center-weighted average";
216 case 3:
217 return "Spot";
218 case 5:
219 return "ESP";
220 case 261:
221 return "Pattern+AF";
222 case 515:
223 return "Spot+Highlight control";
224 case 1027:
225 return "Spot+Shadow control";
226 default:
227 return "Unknown (" + value + ")";
228 }
229 }
230
231 @Nullable
232 public String getExposureShiftDescription()
233 {
234 return getRationalOrDoubleString(TagExposureShift);
235 }
236
237 @Nullable
238 public String getNdFilterDescription()
239 {
240 return getIndexedDescription(TagNdFilter, "Off", "On");
241 }
242
243 @Nullable
244 public String getMacroModeDescription()
245 {
246 return getIndexedDescription(TagMacroMode, "Off", "On", "Super Macro");
247 }
248
249 @Nullable
250 public String getFocusModeDescription()
251 {
252 int[] values = _directory.getIntArray(TagFocusMode);
253 if (values == null) {
254 // check if it's only one value long also
255 Integer value = _directory.getInteger(TagFocusMode);
256 if (value == null)
257 return null;
258
259 values = new int[]{value};
260 }
261
262 if (values.length == 0)
263 return null;
264
265 StringBuilder sb = new StringBuilder();
266 switch (values[0]) {
267 case 0:
268 sb.append("Single AF");
269 break;
270 case 1:
271 sb.append("Sequential shooting AF");
272 break;
273 case 2:
274 sb.append("Continuous AF");
275 break;
276 case 3:
277 sb.append("Multi AF");
278 break;
279 case 4:
280 sb.append("Face detect");
281 break;
282 case 10:
283 sb.append("MF");
284 break;
285 default:
286 sb.append("Unknown (" + values[0] + ")");
287 break;
288 }
289
290 if (values.length > 1) {
291 sb.append("; ");
292 int value1 = values[1];
293
294 if (value1 == 0) {
295 sb.append("(none)");
296 } else {
297 if (( value1 & 1) > 0) sb.append("S-AF, ");
298 if (((value1 >> 2) & 1) > 0) sb.append("C-AF, ");
299 if (((value1 >> 4) & 1) > 0) sb.append("MF, ");
300 if (((value1 >> 5) & 1) > 0) sb.append("Face detect, ");
301 if (((value1 >> 6) & 1) > 0) sb.append("Imager AF, ");
302 if (((value1 >> 7) & 1) > 0) sb.append("Live View Magnification Frame, ");
303 if (((value1 >> 8) & 1) > 0) sb.append("AF sensor, ");
304
305 sb.setLength(sb.length() - 2);
306 }
307 }
308
309 return sb.toString();
310 }
311
312 @Nullable
313 public String getFocusProcessDescription()
314 {
315 int[] values = _directory.getIntArray(TagFocusProcess);
316 if (values == null) {
317 // check if it's only one value long also
318 Integer value = _directory.getInteger(TagFocusProcess);
319 if (value == null)
320 return null;
321
322 values = new int[]{value};
323 }
324
325 if (values.length == 0)
326 return null;
327
328 StringBuilder sb = new StringBuilder();
329
330 switch (values[0]) {
331 case 0:
332 sb.append("AF not used");
333 break;
334 case 1:
335 sb.append("AF used");
336 break;
337 default:
338 sb.append("Unknown (" + values[0] + ")");
339 break;
340 }
341
342 if (values.length > 1)
343 sb.append("; " + values[1]);
344
345 return sb.toString();
346 }
347
348 @Nullable
349 public String getAfSearchDescription()
350 {
351 return getIndexedDescription(TagAfSearch, "Not Ready", "Ready");
352 }
353
354 /** coordinates range from 0 to 255 */
355 @Nullable
356 public String getAfAreasDescription()
357 {
358 Object obj = _directory.getObject(TagAfAreas);
359 if (obj == null || !(obj instanceof long[]))
360 return null;
361
362 StringBuilder sb = new StringBuilder();
363 for (long point : (long[]) obj) {
364 if (point == 0L)
365 continue;
366 if (sb.length() != 0)
367 sb.append(", ");
368
369 if (point == 0x36794285L)
370 sb.append("Left ");
371 else if (point == 0x79798585L)
372 sb.append("Center ");
373 else if (point == 0xBD79C985L)
374 sb.append("Right ");
375
376 sb.append(String.format("(%d/255,%d/255)-(%d/255,%d/255)",
377 (point >> 24) & 0xFF,
378 (point >> 16) & 0xFF,
379 (point >> 8) & 0xFF,
380 point & 0xFF));
381 }
382
383 return sb.length() == 0 ? null : sb.toString();
384 }
385
386 /** coordinates expressed as a percent */
387 @Nullable
388 public String getAfPointSelectedDescription()
389 {
390 Rational[] values = _directory.getRationalArray(TagAfPointSelected);
391 if (values == null)
392 return "n/a";
393
394 if (values.length < 4)
395 return null;
396
397 int index = 0;
398 if (values.length == 5 && values[0].longValue() == 0)
399 index = 1;
400
401 int p1 = (int)(values[index].doubleValue() * 100);
402 int p2 = (int)(values[index + 1].doubleValue() * 100);
403 int p3 = (int)(values[index + 2].doubleValue() * 100);
404 int p4 = (int)(values[index + 3].doubleValue() * 100);
405
406 if(p1 + p2 + p3 + p4 == 0)
407 return "n/a";
408
409 return String.format("(%d%%,%d%%) (%d%%,%d%%)", p1, p2, p3, p4);
410 }
411
412 @Nullable
413 public String getAfFineTuneDescription()
414 {
415 return getIndexedDescription(TagAfFineTune, "Off", "On");
416 }
417
418 @Nullable
419 public String getFlashModeDescription()
420 {
421 Integer value = _directory.getInteger(TagFlashMode);
422 if (value == null)
423 return null;
424
425 if (value == 0)
426 return "Off";
427
428 StringBuilder sb = new StringBuilder();
429 int v = value;
430
431 if (( v & 1) != 0) sb.append("On, ");
432 if (((v >> 1) & 1) != 0) sb.append("Fill-in, ");
433 if (((v >> 2) & 1) != 0) sb.append("Red-eye, ");
434 if (((v >> 3) & 1) != 0) sb.append("Slow-sync, ");
435 if (((v >> 4) & 1) != 0) sb.append("Forced On, ");
436 if (((v >> 5) & 1) != 0) sb.append("2nd Curtain, ");
437
438 return sb.substring(0, sb.length() - 2);
439 }
440
441 @Nullable
442 public String getFlashRemoteControlDescription()
443 {
444 Integer value = _directory.getInteger(TagFlashRemoteControl);
445 if (value == null)
446 return null;
447
448 switch (value) {
449 case 0:
450 return "Off";
451 case 0x01:
452 return "Channel 1, Low";
453 case 0x02:
454 return "Channel 2, Low";
455 case 0x03:
456 return "Channel 3, Low";
457 case 0x04:
458 return "Channel 4, Low";
459 case 0x09:
460 return "Channel 1, Mid";
461 case 0x0a:
462 return "Channel 2, Mid";
463 case 0x0b:
464 return "Channel 3, Mid";
465 case 0x0c:
466 return "Channel 4, Mid";
467 case 0x11:
468 return "Channel 1, High";
469 case 0x12:
470 return "Channel 2, High";
471 case 0x13:
472 return "Channel 3, High";
473 case 0x14:
474 return "Channel 4, High";
475
476 default:
477 return "Unknown (" + value + ")";
478 }
479 }
480
481 /** 3 or 4 values */
482 @Nullable
483 public String getFlashControlModeDescription()
484 {
485 int[] values = _directory.getIntArray(TagFlashControlMode);
486 if (values == null)
487 return null;
488
489 if (values.length == 0)
490 return null;
491
492 StringBuilder sb = new StringBuilder();
493
494 switch (values[0]) {
495 case 0:
496 sb.append("Off");
497 break;
498 case 3:
499 sb.append("TTL");
500 break;
501 case 4:
502 sb.append("Auto");
503 break;
504 case 5:
505 sb.append("Manual");
506 break;
507 default:
508 sb.append("Unknown (").append(values[0]).append(")");
509 break;
510 }
511
512 for (int i = 1; i < values.length; i++)
513 sb.append("; ").append(values[i]);
514
515 return sb.toString();
516 }
517
518 /** 3 or 4 values */
519 @Nullable
520 public String getFlashIntensityDescription()
521 {
522 Rational[] values = _directory.getRationalArray(TagFlashIntensity);
523 if (values == null || values.length == 0)
524 return null;
525
526 if (values.length == 3) {
527 if (values[0].getDenominator() == 0 && values[1].getDenominator() == 0 && values[2].getDenominator() == 0)
528 return "n/a";
529 } else if (values.length == 4) {
530 if (values[0].getDenominator() == 0 && values[1].getDenominator() == 0 && values[2].getDenominator() == 0 && values[3].getDenominator() == 0)
531 return "n/a (x4)";
532 }
533
534 StringBuilder sb = new StringBuilder();
535 for (Rational t : values)
536 sb.append(t).append(", ");
537
538 return sb.substring(0, sb.length() - 2);
539 }
540
541 @Nullable
542 public String getManualFlashStrengthDescription()
543 {
544 Rational[] values = _directory.getRationalArray(TagManualFlashStrength);
545 if (values == null || values.length == 0)
546 return "n/a";
547
548 if (values.length == 3) {
549 if (values[0].getDenominator() == 0 && values[1].getDenominator() == 0 && values[2].getDenominator() == 0)
550 return "n/a";
551 } else if (values.length == 4) {
552 if (values[0].getDenominator() == 0 && values[1].getDenominator() == 0 && values[2].getDenominator() == 0 && values[3].getDenominator() == 0)
553 return "n/a (x4)";
554 }
555
556 StringBuilder sb = new StringBuilder();
557 for (Rational t : values)
558 sb.append(t).append(", ");
559
560 return sb.substring(0, sb.length() - 2);
561 }
562
563 @Nullable
564 public String getWhiteBalance2Description()
565 {
566 Integer value = _directory.getInteger(TagWhiteBalance2);
567 if (value == null)
568 return null;
569
570 switch (value) {
571 case 0:
572 return "Auto";
573 case 1:
574 return "Auto (Keep Warm Color Off)";
575 case 16:
576 return "7500K (Fine Weather with Shade)";
577 case 17:
578 return "6000K (Cloudy)";
579 case 18:
580 return "5300K (Fine Weather)";
581 case 20:
582 return "3000K (Tungsten light)";
583 case 21:
584 return "3600K (Tungsten light-like)";
585 case 22:
586 return "Auto Setup";
587 case 23:
588 return "5500K (Flash)";
589 case 33:
590 return "6600K (Daylight fluorescent)";
591 case 34:
592 return "4500K (Neutral white fluorescent)";
593 case 35:
594 return "4000K (Cool white fluorescent)";
595 case 36:
596 return "White Fluorescent";
597 case 48:
598 return "3600K (Tungsten light-like)";
599 case 67:
600 return "Underwater";
601 case 256:
602 return "One Touch WB 1";
603 case 257:
604 return "One Touch WB 2";
605 case 258:
606 return "One Touch WB 3";
607 case 259:
608 return "One Touch WB 4";
609 case 512:
610 return "Custom WB 1";
611 case 513:
612 return "Custom WB 2";
613 case 514:
614 return "Custom WB 3";
615 case 515:
616 return "Custom WB 4";
617 default:
618 return "Unknown (" + value + ")";
619 }
620 }
621
622 @Nullable
623 public String getWhiteBalanceTemperatureDescription()
624 {
625 Integer value = _directory.getInteger(TagWhiteBalanceTemperature);
626 if (value == null)
627 return null;
628 if (value == 0)
629 return "Auto";
630 return value.toString();
631 }
632
633 @Nullable
634 public String getCustomSaturationDescription()
635 {
636 // TODO: if model is /^E-1\b/ then
637 // $a-=$b; $c-=$b;
638 // return "CS$a (min CS0, max CS$c)"
639 return getValueMinMaxDescription(TagCustomSaturation);
640 }
641
642 @Nullable
643 public String getModifiedSaturationDescription()
644 {
645 return getIndexedDescription(TagModifiedSaturation,
646 "Off", "CM1 (Red Enhance)", "CM2 (Green Enhance)", "CM3 (Blue Enhance)", "CM4 (Skin Tones)");
647 }
648
649 @Nullable
650 public String getContrastSettingDescription()
651 {
652 return getValueMinMaxDescription(TagContrastSetting);
653 }
654
655 @Nullable
656 public String getSharpnessSettingDescription()
657 {
658 return getValueMinMaxDescription(TagSharpnessSetting);
659 }
660
661 @Nullable
662 public String getColorSpaceDescription()
663 {
664 return getIndexedDescription(TagColorSpace,
665 "sRGB", "Adobe RGB", "Pro Photo RGB");
666 }
667
668 @Nullable
669 public String getSceneModeDescription()
670 {
671 Integer value = _directory.getInteger(TagSceneMode);
672 if (value == null)
673 return null;
674
675 switch (value) {
676 case 0:
677 return "Standard";
678 case 6:
679 return "Auto";
680 case 7:
681 return "Sport";
682 case 8:
683 return "Portrait";
684 case 9:
685 return "Landscape+Portrait";
686 case 10:
687 return "Landscape";
688 case 11:
689 return "Night Scene";
690 case 12:
691 return "Self Portrait";
692 case 13:
693 return "Panorama";
694 case 14:
695 return "2 in 1";
696 case 15:
697 return "Movie";
698 case 16:
699 return "Landscape+Portrait";
700 case 17:
701 return "Night+Portrait";
702 case 18:
703 return "Indoor";
704 case 19:
705 return "Fireworks";
706 case 20:
707 return "Sunset";
708 case 21:
709 return "Beauty Skin";
710 case 22:
711 return "Macro";
712 case 23:
713 return "Super Macro";
714 case 24:
715 return "Food";
716 case 25:
717 return "Documents";
718 case 26:
719 return "Museum";
720 case 27:
721 return "Shoot & Select";
722 case 28:
723 return "Beach & Snow";
724 case 29:
725 return "Self Portrait+Timer";
726 case 30:
727 return "Candle";
728 case 31:
729 return "Available Light";
730 case 32:
731 return "Behind Glass";
732 case 33:
733 return "My Mode";
734 case 34:
735 return "Pet";
736 case 35:
737 return "Underwater Wide1";
738 case 36:
739 return "Underwater Macro";
740 case 37:
741 return "Shoot & Select1";
742 case 38:
743 return "Shoot & Select2";
744 case 39:
745 return "High Key";
746 case 40:
747 return "Digital Image Stabilization";
748 case 41:
749 return "Auction";
750 case 42:
751 return "Beach";
752 case 43:
753 return "Snow";
754 case 44:
755 return "Underwater Wide2";
756 case 45:
757 return "Low Key";
758 case 46:
759 return "Children";
760 case 47:
761 return "Vivid";
762 case 48:
763 return "Nature Macro";
764 case 49:
765 return "Underwater Snapshot";
766 case 50:
767 return "Shooting Guide";
768 case 54:
769 return "Face Portrait";
770 case 57:
771 return "Bulb";
772 case 59:
773 return "Smile Shot";
774 case 60:
775 return "Quick Shutter";
776 case 63:
777 return "Slow Shutter";
778 case 64:
779 return "Bird Watching";
780 case 65:
781 return "Multiple Exposure";
782 case 66:
783 return "e-Portrait";
784 case 67:
785 return "Soft Background Shot";
786 case 142:
787 return "Hand-held Starlight";
788 case 154:
789 return "HDR";
790 default:
791 return "Unknown (" + value + ")";
792 }
793 }
794
795 @Nullable
796 public String getNoiseReductionDescription()
797 {
798 Integer value = _directory.getInteger(TagNoiseReduction);
799 if (value == null)
800 return null;
801
802 if (value == 0)
803 return "(none)";
804
805 StringBuilder sb = new StringBuilder();
806 int v = value;
807
808 if ((v & 1) != 0) sb.append("Noise Reduction, ");
809 if (((v >> 1) & 1) != 0) sb.append("Noise Filter, ");
810 if (((v >> 2) & 1) != 0) sb.append("Noise Filter (ISO Boost), ");
811 if (((v >> 3) & 1) != 0) sb.append("Auto, ");
812
813 return sb.length() != 0
814 ? sb.substring(0, sb.length() - 2)
815 : "(none)";
816 }
817
818 @Nullable
819 public String getDistortionCorrectionDescription()
820 {
821 return getIndexedDescription(TagDistortionCorrection, "Off", "On");
822 }
823
824 @Nullable
825 public String getShadingCompensationDescription()
826 {
827 return getIndexedDescription(TagShadingCompensation, "Off", "On");
828 }
829
830 /** 3 or 4 values */
831 @Nullable
832 public String getGradationDescription()
833 {
834 int[] values = _directory.getIntArray(TagGradation);
835 if (values == null || values.length < 3)
836 return null;
837
838 String join = String.format("%d %d %d", values[0], values[1], values[2]);
839
840 String ret;
841 if (join.equals("0 0 0")) {
842 ret = "n/a";
843 } else if (join.equals("-1 -1 1")) {
844 ret = "Low Key";
845 } else if (join.equals("0 -1 1")) {
846 ret = "Normal";
847 } else if (join.equals("1 -1 1")) {
848 ret = "High Key";
849 } else {
850 ret = "Unknown (" + join + ")";
851 }
852
853 if (values.length > 3) {
854 if (values[3] == 0)
855 ret += "; User-Selected";
856 else if (values[3] == 1)
857 ret += "; Auto-Override";
858 }
859
860 return ret;
861 }
862
863 /** 1 or 2 values */
864 @Nullable
865 public String getPictureModeDescription()
866 {
867 int[] values = _directory.getIntArray(TagPictureMode);
868 if (values == null) {
869 // check if it's only one value long also
870 Integer value = _directory.getInteger(TagNoiseReduction);
871 if (value == null)
872 return null;
873
874 values = new int[]{value};
875 }
876
877 if (values.length == 0)
878 return null;
879
880 StringBuilder sb = new StringBuilder();
881 switch (values[0]) {
882 case 1:
883 sb.append("Vivid");
884 break;
885 case 2:
886 sb.append("Natural");
887 break;
888 case 3:
889 sb.append("Muted");
890 break;
891 case 4:
892 sb.append("Portrait");
893 break;
894 case 5:
895 sb.append("i-Enhance");
896 break;
897 case 256:
898 sb.append("Monotone");
899 break;
900 case 512:
901 sb.append("Sepia");
902 break;
903 default:
904 sb.append("Unknown (").append(values[0]).append(")");
905 break;
906 }
907
908 if (values.length > 1)
909 sb.append("; ").append(values[1]);
910
911 return sb.toString();
912 }
913
914 @Nullable
915 public String getPictureModeSaturationDescription()
916 {
917 return getValueMinMaxDescription(TagPictureModeSaturation);
918 }
919
920 @Nullable
921 public String getPictureModeContrastDescription()
922 {
923 return getValueMinMaxDescription(TagPictureModeContrast);
924 }
925
926 @Nullable
927 public String getPictureModeSharpnessDescription()
928 {
929 return getValueMinMaxDescription(TagPictureModeSharpness);
930 }
931
932 @Nullable
933 public String getPictureModeBWFilterDescription()
934 {
935 return getIndexedDescription(TagPictureModeBWFilter,
936 "n/a", "Neutral", "Yellow", "Orange", "Red", "Green");
937 }
938
939 @Nullable
940 public String getPictureModeToneDescription()
941 {
942 return getIndexedDescription(TagPictureModeTone,
943 "n/a", "Neutral", "Sepia", "Blue", "Purple", "Green");
944 }
945
946 @Nullable
947 public String getNoiseFilterDescription()
948 {
949 int[] values = _directory.getIntArray(TagNoiseFilter);
950 if (values == null)
951 return null;
952
953 String join = String.format("%d %d %d", values[0], values[1], values[2]);
954
955 if (join.equals("0 0 0"))
956 return "n/a";
957 if (join.equals("-2 -2 1"))
958 return "Off";
959 if (join.equals("-1 -2 1"))
960 return "Low";
961 if (join.equals("0 -2 1"))
962 return "Standard";
963 if (join.equals("1 -2 1"))
964 return "High";
965 return "Unknown (" + join + ")";
966 }
967
968 @Nullable
969 public String getArtFilterDescription()
970 {
971 return getFiltersDescription(TagArtFilter);
972 }
973
974 @Nullable
975 public String getMagicFilterDescription()
976 {
977 return getFiltersDescription(TagMagicFilter);
978 }
979
980 @Nullable
981 public String getPictureModeEffectDescription()
982 {
983 int[] values = _directory.getIntArray(TagPictureModeEffect);
984 if (values == null)
985 return null;
986
987 String key = String.format("%d %d %d", values[0], values[1], values[2]);
988 if (key.equals("0 0 0"))
989 return "n/a";
990 if (key.equals("-1 -1 1"))
991 return "Low";
992 if (key.equals("0 -1 1"))
993 return "Standard";
994 if (key.equals("1 -1 1"))
995 return "High";
996 return "Unknown (" + key + ")";
997 }
998
999 @Nullable
1000 public String getToneLevelDescription()
1001 {
1002 int[] values = _directory.getIntArray(TagToneLevel);
1003 if (values == null || values.length == 0)
1004 return null;
1005
1006 StringBuilder sb = new StringBuilder();
1007 for (int i = 0; i < values.length; i++) {
1008 if (i == 0 || i == 4 || i == 8 || i == 12 || i == 16 || i == 20 || i == 24)
1009 sb.append(_toneLevelType.get(values[i])).append("; ");
1010 else
1011 sb.append(values[i]).append("; ");
1012 }
1013
1014 return sb.substring(0, sb.length() - 2);
1015 }
1016
1017 @Nullable
1018 public String getArtFilterEffectDescription()
1019 {
1020 int[] values = _directory.getIntArray(TagArtFilterEffect);
1021 if (values == null)
1022 return null;
1023
1024 StringBuilder sb = new StringBuilder();
1025 for (int i = 0; i < values.length; i++) {
1026 if (i == 0) {
1027 sb.append((_filters.containsKey(values[i]) ? _filters.get(values[i]) : "[unknown]")).append("; ");
1028 } else if (i == 3) {
1029 sb.append("Partial Color ").append(values[i]).append("; ");
1030 } else if (i == 4) {
1031 switch (values[i]) {
1032 case 0x0000:
1033 sb.append("No Effect");
1034 break;
1035 case 0x8010:
1036 sb.append("Star Light");
1037 break;
1038 case 0x8020:
1039 sb.append("Pin Hole");
1040 break;
1041 case 0x8030:
1042 sb.append("Frame");
1043 break;
1044 case 0x8040:
1045 sb.append("Soft Focus");
1046 break;
1047 case 0x8050:
1048 sb.append("White Edge");
1049 break;
1050 case 0x8060:
1051 sb.append("B&W");
1052 break;
1053 default:
1054 sb.append("Unknown (").append(values[i]).append(")");
1055 break;
1056 }
1057 sb.append("; ");
1058 } else if (i == 6) {
1059 switch (values[i]) {
1060 case 0:
1061 sb.append("No Color Filter");
1062 break;
1063 case 1:
1064 sb.append("Yellow Color Filter");
1065 break;
1066 case 2:
1067 sb.append("Orange Color Filter");
1068 break;
1069 case 3:
1070 sb.append("Red Color Filter");
1071 break;
1072 case 4:
1073 sb.append("Green Color Filter");
1074 break;
1075 default:
1076 sb.append("Unknown (").append(values[i]).append(")");
1077 break;
1078 }
1079 sb.append("; ");
1080 } else {
1081 sb.append(values[i]).append("; ");
1082 }
1083 }
1084
1085 return sb.substring(0, sb.length() - 2);
1086 }
1087
1088 @Nullable
1089 public String getColorCreatorEffectDescription()
1090 {
1091 int[] values = _directory.getIntArray(TagColorCreatorEffect);
1092 if (values == null)
1093 return null;
1094
1095 StringBuilder sb = new StringBuilder();
1096 for (int i = 0; i < values.length; i++) {
1097 if (i == 0) {
1098 sb.append("Color ").append(values[i]).append("; ");
1099 } else if (i == 3) {
1100 sb.append("Strength ").append(values[i]).append("; ");
1101 } else {
1102 sb.append(values[i]).append("; ");
1103 }
1104 }
1105
1106 return sb.substring(0, sb.length() - 2);
1107 }
1108
1109 /** 2 or 3 numbers: 1. Mode, 2. Shot number, 3. Mode bits */
1110 @Nullable
1111 public String getDriveModeDescription()
1112 {
1113 int[] values = _directory.getIntArray(TagDriveMode);
1114 if (values == null)
1115 return null;
1116
1117 if (values.length == 0 || values[0] == 0)
1118 return "Single Shot";
1119
1120 StringBuilder a = new StringBuilder();
1121
1122 if (values[0] == 5 && values.length >= 3) {
1123 int c = values[2];
1124 if (( c & 1) > 0) a.append("AE");
1125 if (((c >> 1) & 1) > 0) a.append("WB");
1126 if (((c >> 2) & 1) > 0) a.append("FL");
1127 if (((c >> 3) & 1) > 0) a.append("MF");
1128 if (((c >> 6) & 1) > 0) a.append("Focus");
1129
1130 a.append(" Bracketing");
1131 } else {
1132 switch (values[0]) {
1133 case 1:
1134 a.append("Continuous Shooting");
1135 break;
1136 case 2:
1137 a.append("Exposure Bracketing");
1138 break;
1139 case 3:
1140 a.append("White Balance Bracketing");
1141 break;
1142 case 4:
1143 a.append("Exposure+WB Bracketing");
1144 break;
1145 default:
1146 a.append("Unknown (").append(values[0]).append(")");
1147 break;
1148 }
1149 }
1150
1151 a.append(", Shot ").append(values[1]);
1152
1153 return a.toString();
1154 }
1155
1156 /** 2 numbers: 1. Mode, 2. Shot number */
1157 @Nullable
1158 public String getPanoramaModeDescription()
1159 {
1160 int[] values = _directory.getIntArray(TagPanoramaMode);
1161 if (values == null)
1162 return null;
1163
1164 if (values.length == 0 || values[0] == 0)
1165 return "Off";
1166
1167 String a;
1168 switch (values[0]) {
1169 case 1:
1170 a = "Left to Right";
1171 break;
1172 case 2:
1173 a = "Right to Left";
1174 break;
1175 case 3:
1176 a = "Bottom to Top";
1177 break;
1178 case 4:
1179 a = "Top to Bottom";
1180 break;
1181 default:
1182 a = "Unknown (" + values[0] + ")";
1183 break;
1184 }
1185
1186 return String.format("%s, Shot %d", a, values[1]);
1187 }
1188
1189 @Nullable
1190 public String getImageQuality2Description()
1191 {
1192 return getIndexedDescription(TagImageQuality2, 1,
1193 "SQ", "HQ", "SHQ", "RAW", "SQ (5)");
1194 }
1195
1196 @Nullable
1197 public String getImageStabilizationDescription()
1198 {
1199 return getIndexedDescription(TagImageStabilization,
1200 "Off", "On, Mode 1", "On, Mode 2", "On, Mode 3", "On, Mode 4");
1201 }
1202
1203 @Nullable
1204 public String getStackedImageDescription()
1205 {
1206 int[] values = _directory.getIntArray(TagStackedImage);
1207 if (values == null || values.length < 2)
1208 return null;
1209
1210 int v1 = values[0];
1211 int v2 = values[1];
1212
1213 if (v1 == 0 && v2 == 0)
1214 return "No";
1215 if (v1 == 9 && v2 == 8)
1216 return "Focus-stacked (8 images)";
1217
1218 return String.format("Unknown (%d %d)", v1, v2);
1219 }
1220
1221 /// <remarks>
1222 /// TODO: need better image examples to test this function
1223 /// </remarks>
1224 /// <returns></returns>
1225 @Nullable
1226 public String getManometerPressureDescription()
1227 {
1228 Integer value = _directory.getInteger(TagManometerPressure);
1229 if (value == null)
1230 return null;
1231
1232 return String.format("%s kPa", new DecimalFormat("#.##").format(value / 10.0));
1233 }
1234
1235 /// <remarks>
1236 /// TODO: need better image examples to test this function
1237 /// </remarks>
1238 /// <returns></returns>
1239 @Nullable
1240 public String getManometerReadingDescription()
1241 {
1242 int[] values = _directory.getIntArray(TagManometerReading);
1243 if (values == null || values.length < 2)
1244 return null;
1245
1246 DecimalFormat format = new DecimalFormat("#.##");
1247 return String.format("%s m, %s ft",
1248 format.format(values[0] / 10.0),
1249 format.format(values[1] / 10.0));
1250 }
1251
1252 @Nullable
1253 public String getExtendedWBDetectDescription()
1254 {
1255 return getIndexedDescription(TagExtendedWBDetect, "Off", "On");
1256 }
1257
1258 /** converted to degrees of clockwise camera rotation */
1259 // TODO: need better image examples to test this function
1260 @Nullable
1261 public String getRollAngleDescription()
1262 {
1263 int[] values = _directory.getIntArray(TagRollAngle);
1264 if (values == null || values.length < 2)
1265 return null;
1266
1267 String ret = values[0] != 0
1268 ? Double.toString(-values[0] / 10.0)
1269 : "n/a";
1270
1271 return String.format("%s %d", ret, values[1]);
1272 }
1273
1274 /** converted to degrees of upward camera tilt */
1275 // TODO: need better image examples to test this function
1276 @Nullable
1277 public String getPitchAngleDescription()
1278 {
1279 int[] values = _directory.getIntArray(TagPitchAngle);
1280 if (values == null || values.length < 2)
1281 return null;
1282
1283 // (second value is 0 if level gauge is off)
1284 String ret = values[0] != 0
1285 ? Double.toString(values[0] / 10.0)
1286 : "n/a";
1287
1288 return String.format("%s %d", ret, values[1]);
1289 }
1290
1291 @Nullable
1292 public String getDateTimeUTCDescription()
1293 {
1294 Object value = _directory.getObject(TagDateTimeUtc);
1295 if (value == null)
1296 return null;
1297 return value.toString();
1298 }
1299
1300 @Nullable
1301 private String getValueMinMaxDescription(int tagId)
1302 {
1303 int[] values = _directory.getIntArray(tagId);
1304 if (values == null || values.length < 3)
1305 return null;
1306
1307 return String.format("%d (min %d, max %d)", values[0], values[1], values[2]);
1308 }
1309
1310 @Nullable
1311 private String getFiltersDescription(int tagId)
1312 {
1313 int[] values = _directory.getIntArray(tagId);
1314 if (values == null || values.length == 0)
1315 return null;
1316
1317 StringBuilder sb = new StringBuilder();
1318 for (int i = 0; i < values.length; i++) {
1319 if (i == 0)
1320 sb.append(_filters.containsKey(values[i]) ? _filters.get(values[i]) : "[unknown]");
1321 else
1322 sb.append(values[i]);
1323 sb.append("; ");
1324 }
1325
1326 return sb.substring(0, sb.length() - 2);
1327 }
1328
1329 private static final HashMap<Integer, String> _toneLevelType = new HashMap<Integer, String>();
1330 // ArtFilter, ArtFilterEffect and MagicFilter values
1331 private static final HashMap<Integer, String> _filters = new HashMap<Integer, String>();
1332
1333 static {
1334 _filters.put(0, "Off");
1335 _filters.put(1, "Soft Focus");
1336 _filters.put(2, "Pop Art");
1337 _filters.put(3, "Pale & Light Color");
1338 _filters.put(4, "Light Tone");
1339 _filters.put(5, "Pin Hole");
1340 _filters.put(6, "Grainy Film");
1341 _filters.put(9, "Diorama");
1342 _filters.put(10, "Cross Process");
1343 _filters.put(12, "Fish Eye");
1344 _filters.put(13, "Drawing");
1345 _filters.put(14, "Gentle Sepia");
1346 _filters.put(15, "Pale & Light Color II");
1347 _filters.put(16, "Pop Art II");
1348 _filters.put(17, "Pin Hole II");
1349 _filters.put(18, "Pin Hole III");
1350 _filters.put(19, "Grainy Film II");
1351 _filters.put(20, "Dramatic Tone");
1352 _filters.put(21, "Punk");
1353 _filters.put(22, "Soft Focus 2");
1354 _filters.put(23, "Sparkle");
1355 _filters.put(24, "Watercolor");
1356 _filters.put(25, "Key Line");
1357 _filters.put(26, "Key Line II");
1358 _filters.put(27, "Miniature");
1359 _filters.put(28, "Reflection");
1360 _filters.put(29, "Fragmented");
1361 _filters.put(31, "Cross Process II");
1362 _filters.put(32, "Dramatic Tone II");
1363 _filters.put(33, "Watercolor I");
1364 _filters.put(34, "Watercolor II");
1365 _filters.put(35, "Diorama II");
1366 _filters.put(36, "Vintage");
1367 _filters.put(37, "Vintage II");
1368 _filters.put(38, "Vintage III");
1369 _filters.put(39, "Partial Color");
1370 _filters.put(40, "Partial Color II");
1371 _filters.put(41, "Partial Color III");
1372
1373 _toneLevelType.put(0, "0");
1374 _toneLevelType.put(-31999, "Highlights ");
1375 _toneLevelType.put(-31998, "Shadows ");
1376 _toneLevelType.put(-31997, "Midtones ");
1377 }
1378 }