source: josm/trunk/src/com/drew/metadata/exif/makernotes/OlympusMakernoteDescriptor.java@ 13500

Last change on this file since 13500 was 13061, checked in by Don-vip, 6 years ago

fix #15505 - update to metadata-extractor 2.10.1

File size: 31.9 KB
Line 
1/*
2 * Copyright 2002-2017 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 */
21package com.drew.metadata.exif.makernotes;
22
23import com.drew.imaging.PhotographicConversions;
24import com.drew.lang.Rational;
25import com.drew.lang.DateUtil;
26import com.drew.lang.annotations.NotNull;
27import com.drew.lang.annotations.Nullable;
28import com.drew.metadata.TagDescriptor;
29
30import java.math.RoundingMode;
31import java.text.DecimalFormat;
32
33import static com.drew.metadata.exif.makernotes.OlympusMakernoteDirectory.*;
34
35/**
36 * Provides human-readable string representations of tag values stored in a {@link OlympusMakernoteDirectory}.
37 *
38 * @author Drew Noakes https://drewnoakes.com
39 */
40@SuppressWarnings("WeakerAccess")
41public class OlympusMakernoteDescriptor extends TagDescriptor<OlympusMakernoteDirectory>
42{
43 // TODO extend support for some offset-encoded byte[] tags: http://www.ozhiker.com/electronics/pjmt/jpeg_info/olympus_mn.html
44
45 public OlympusMakernoteDescriptor(@NotNull OlympusMakernoteDirectory directory)
46 {
47 super(directory);
48 }
49
50 @Override
51 @Nullable
52 public String getDescription(int tagType)
53 {
54 switch (tagType) {
55 case TAG_MAKERNOTE_VERSION:
56 return getMakernoteVersionDescription();
57 case TAG_COLOUR_MODE:
58 return getColorModeDescription();
59 case TAG_IMAGE_QUALITY_1:
60 return getImageQuality1Description();
61 case TAG_IMAGE_QUALITY_2:
62 return getImageQuality2Description();
63 case TAG_SPECIAL_MODE:
64 return getSpecialModeDescription();
65 case TAG_JPEG_QUALITY:
66 return getJpegQualityDescription();
67 case TAG_MACRO_MODE:
68 return getMacroModeDescription();
69 case TAG_BW_MODE:
70 return getBWModeDescription();
71 case TAG_DIGITAL_ZOOM:
72 return getDigitalZoomDescription();
73 case TAG_FOCAL_PLANE_DIAGONAL:
74 return getFocalPlaneDiagonalDescription();
75 case TAG_CAMERA_TYPE:
76 return getCameraTypeDescription();
77 case TAG_CAMERA_ID:
78 return getCameraIdDescription();
79 case TAG_ONE_TOUCH_WB:
80 return getOneTouchWbDescription();
81 case TAG_SHUTTER_SPEED_VALUE:
82 return getShutterSpeedDescription();
83 case TAG_ISO_VALUE:
84 return getIsoValueDescription();
85 case TAG_APERTURE_VALUE:
86 return getApertureValueDescription();
87 case TAG_FLASH_MODE:
88 return getFlashModeDescription();
89 case TAG_FOCUS_RANGE:
90 return getFocusRangeDescription();
91 case TAG_FOCUS_MODE:
92 return getFocusModeDescription();
93 case TAG_SHARPNESS:
94 return getSharpnessDescription();
95 case TAG_COLOUR_MATRIX:
96 return getColorMatrixDescription();
97 case TAG_WB_MODE:
98 return getWbModeDescription();
99 case TAG_RED_BALANCE:
100 return getRedBalanceDescription();
101 case TAG_BLUE_BALANCE:
102 return getBlueBalanceDescription();
103 case TAG_CONTRAST:
104 return getContrastDescription();
105 case TAG_PREVIEW_IMAGE_VALID:
106 return getPreviewImageValidDescription();
107
108 case CameraSettings.TAG_EXPOSURE_MODE:
109 return getExposureModeDescription();
110 case CameraSettings.TAG_FLASH_MODE:
111 return getFlashModeCameraSettingDescription();
112 case CameraSettings.TAG_WHITE_BALANCE:
113 return getWhiteBalanceDescription();
114 case CameraSettings.TAG_IMAGE_SIZE:
115 return getImageSizeDescription();
116 case CameraSettings.TAG_IMAGE_QUALITY:
117 return getImageQualityDescription();
118 case CameraSettings.TAG_SHOOTING_MODE:
119 return getShootingModeDescription();
120 case CameraSettings.TAG_METERING_MODE:
121 return getMeteringModeDescription();
122 case CameraSettings.TAG_APEX_FILM_SPEED_VALUE:
123 return getApexFilmSpeedDescription();
124 case CameraSettings.TAG_APEX_SHUTTER_SPEED_TIME_VALUE:
125 return getApexShutterSpeedTimeDescription();
126 case CameraSettings.TAG_APEX_APERTURE_VALUE:
127 return getApexApertureDescription();
128 case CameraSettings.TAG_MACRO_MODE:
129 return getMacroModeCameraSettingDescription();
130 case CameraSettings.TAG_DIGITAL_ZOOM:
131 return getDigitalZoomCameraSettingDescription();
132 case CameraSettings.TAG_EXPOSURE_COMPENSATION:
133 return getExposureCompensationDescription();
134 case CameraSettings.TAG_BRACKET_STEP:
135 return getBracketStepDescription();
136
137 case CameraSettings.TAG_INTERVAL_LENGTH:
138 return getIntervalLengthDescription();
139 case CameraSettings.TAG_INTERVAL_NUMBER:
140 return getIntervalNumberDescription();
141 case CameraSettings.TAG_FOCAL_LENGTH:
142 return getFocalLengthDescription();
143 case CameraSettings.TAG_FOCUS_DISTANCE:
144 return getFocusDistanceDescription();
145 case CameraSettings.TAG_FLASH_FIRED:
146 return getFlashFiredDescription();
147 case CameraSettings.TAG_DATE:
148 return getDateDescription();
149 case CameraSettings.TAG_TIME:
150 return getTimeDescription();
151 case CameraSettings.TAG_MAX_APERTURE_AT_FOCAL_LENGTH:
152 return getMaxApertureAtFocalLengthDescription();
153
154 case CameraSettings.TAG_FILE_NUMBER_MEMORY:
155 return getFileNumberMemoryDescription();
156 case CameraSettings.TAG_LAST_FILE_NUMBER:
157 return getLastFileNumberDescription();
158 case CameraSettings.TAG_WHITE_BALANCE_RED:
159 return getWhiteBalanceRedDescription();
160 case CameraSettings.TAG_WHITE_BALANCE_GREEN:
161 return getWhiteBalanceGreenDescription();
162 case CameraSettings.TAG_WHITE_BALANCE_BLUE:
163 return getWhiteBalanceBlueDescription();
164 case CameraSettings.TAG_SATURATION:
165 return getSaturationDescription();
166 case CameraSettings.TAG_CONTRAST:
167 return getContrastCameraSettingDescription();
168 case CameraSettings.TAG_SHARPNESS:
169 return getSharpnessCameraSettingDescription();
170 case CameraSettings.TAG_SUBJECT_PROGRAM:
171 return getSubjectProgramDescription();
172 case CameraSettings.TAG_FLASH_COMPENSATION:
173 return getFlashCompensationDescription();
174 case CameraSettings.TAG_ISO_SETTING:
175 return getIsoSettingDescription();
176 case CameraSettings.TAG_CAMERA_MODEL:
177 return getCameraModelDescription();
178 case CameraSettings.TAG_INTERVAL_MODE:
179 return getIntervalModeDescription();
180 case CameraSettings.TAG_FOLDER_NAME:
181 return getFolderNameDescription();
182 case CameraSettings.TAG_COLOR_MODE:
183 return getColorModeCameraSettingDescription();
184 case CameraSettings.TAG_COLOR_FILTER:
185 return getColorFilterDescription();
186 case CameraSettings.TAG_BLACK_AND_WHITE_FILTER:
187 return getBlackAndWhiteFilterDescription();
188 case CameraSettings.TAG_INTERNAL_FLASH:
189 return getInternalFlashDescription();
190 case CameraSettings.TAG_APEX_BRIGHTNESS_VALUE:
191 return getApexBrightnessDescription();
192 case CameraSettings.TAG_SPOT_FOCUS_POINT_X_COORDINATE:
193 return getSpotFocusPointXCoordinateDescription();
194 case CameraSettings.TAG_SPOT_FOCUS_POINT_Y_COORDINATE:
195 return getSpotFocusPointYCoordinateDescription();
196 case CameraSettings.TAG_WIDE_FOCUS_ZONE:
197 return getWideFocusZoneDescription();
198 case CameraSettings.TAG_FOCUS_MODE:
199 return getFocusModeCameraSettingDescription();
200 case CameraSettings.TAG_FOCUS_AREA:
201 return getFocusAreaDescription();
202 case CameraSettings.TAG_DEC_SWITCH_POSITION:
203 return getDecSwitchPositionDescription();
204
205 default:
206 return super.getDescription(tagType);
207 }
208 }
209
210 @Nullable
211 public String getExposureModeDescription()
212 {
213 return getIndexedDescription(CameraSettings.TAG_EXPOSURE_MODE, "P", "A", "S", "M");
214 }
215
216 @Nullable
217 public String getFlashModeCameraSettingDescription()
218 {
219 return getIndexedDescription(CameraSettings.TAG_FLASH_MODE,
220 "Normal", "Red-eye reduction", "Rear flash sync", "Wireless");
221 }
222
223 @Nullable
224 public String getWhiteBalanceDescription()
225 {
226 return getIndexedDescription(CameraSettings.TAG_WHITE_BALANCE,
227 "Auto", // 0
228 "Daylight",
229 "Cloudy",
230 "Tungsten",
231 null,
232 "Custom", // 5
233 null,
234 "Fluorescent",
235 "Fluorescent 2",
236 null,
237 null, // 10
238 "Custom 2",
239 "Custom 3"
240 );
241 }
242
243 @Nullable
244 public String getImageSizeDescription()
245 {
246 // This is a pretty weird way to store this information!
247 return getIndexedDescription(CameraSettings.TAG_IMAGE_SIZE, "2560 x 1920", "1600 x 1200", "1280 x 960", "640 x 480");
248 }
249
250 @Nullable
251 public String getImageQualityDescription()
252 {
253 return getIndexedDescription(CameraSettings.TAG_IMAGE_QUALITY, "Raw", "Super Fine", "Fine", "Standard", "Economy", "Extra Fine");
254 }
255
256 @Nullable
257 public String getShootingModeDescription()
258 {
259 return getIndexedDescription(CameraSettings.TAG_SHOOTING_MODE,
260 "Single",
261 "Continuous",
262 "Self Timer",
263 null,
264 "Bracketing",
265 "Interval",
266 "UHS Continuous",
267 "HS Continuous"
268 );
269 }
270
271 @Nullable
272 public String getMeteringModeDescription()
273 {
274 return getIndexedDescription(CameraSettings.TAG_METERING_MODE, "Multi-Segment", "Centre Weighted", "Spot");
275 }
276
277 @Nullable
278 public String getApexFilmSpeedDescription()
279 {
280 // http://www.ozhiker.com/electronics/pjmt/jpeg_info/minolta_mn.html#Minolta_Camera_Settings
281 // Apex Speed value = value/8-1 ,
282 // ISO = (2^(value/8-1))*3.125
283 Long value = _directory.getLongObject(CameraSettings.TAG_APEX_FILM_SPEED_VALUE);
284
285 if (value == null)
286 return null;
287
288 double iso = Math.pow((value / 8d) - 1, 2) * 3.125;
289 DecimalFormat format = new DecimalFormat("0.##");
290 format.setRoundingMode(RoundingMode.HALF_UP);
291 return format.format(iso);
292 }
293
294 @Nullable
295 public String getApexShutterSpeedTimeDescription()
296 {
297 // http://www.ozhiker.com/electronics/pjmt/jpeg_info/minolta_mn.html#Minolta_Camera_Settings
298 // Apex Time value = value/8-6 ,
299 // ShutterSpeed = 2^( (48-value)/8 ),
300 // Due to rounding error value=8 should be displayed as 30 sec.
301 Long value = _directory.getLongObject(CameraSettings.TAG_APEX_SHUTTER_SPEED_TIME_VALUE);
302
303 if (value == null)
304 return null;
305
306 double shutterSpeed = Math.pow((49-value) / 8d, 2);
307 DecimalFormat format = new DecimalFormat("0.###");
308 format.setRoundingMode(RoundingMode.HALF_UP);
309 return format.format(shutterSpeed) + " sec";
310 }
311
312 @Nullable
313 public String getApexApertureDescription()
314 {
315 // http://www.ozhiker.com/electronics/pjmt/jpeg_info/minolta_mn.html#Minolta_Camera_Settings
316 // Apex Aperture Value = value/8-1 ,
317 // Aperture F-stop = 2^( value/16-0.5 )
318 Long value = _directory.getLongObject(CameraSettings.TAG_APEX_APERTURE_VALUE);
319
320 if (value == null)
321 return null;
322
323 double fStop = Math.pow((value/16d) - 0.5, 2);
324 return getFStopDescription(fStop);
325 }
326
327 @Nullable
328 public String getMacroModeCameraSettingDescription()
329 {
330 return getIndexedDescription(CameraSettings.TAG_MACRO_MODE, "Off", "On");
331 }
332
333 @Nullable
334 public String getDigitalZoomCameraSettingDescription()
335 {
336 return getIndexedDescription(CameraSettings.TAG_DIGITAL_ZOOM, "Off", "Electronic magnification", "Digital zoom 2x");
337 }
338
339 @Nullable
340 public String getExposureCompensationDescription()
341 {
342 Long value = _directory.getLongObject(CameraSettings.TAG_EXPOSURE_COMPENSATION);
343 DecimalFormat format = new DecimalFormat("0.##");
344 return value == null ? null : format.format((value / 3d) - 2) + " EV";
345 }
346
347 @Nullable
348 public String getBracketStepDescription()
349 {
350 return getIndexedDescription(CameraSettings.TAG_BRACKET_STEP, "1/3 EV", "2/3 EV", "1 EV");
351 }
352
353 @Nullable
354 public String getIntervalLengthDescription()
355 {
356 if (!_directory.isIntervalMode())
357 return "N/A";
358
359 Long value = _directory.getLongObject(CameraSettings.TAG_INTERVAL_LENGTH);
360 return value == null ? null : value + " min";
361 }
362
363 @Nullable
364 public String getIntervalNumberDescription()
365 {
366 if (!_directory.isIntervalMode())
367 return "N/A";
368
369 Long value = _directory.getLongObject(CameraSettings.TAG_INTERVAL_NUMBER);
370 return value == null ? null : Long.toString(value);
371 }
372
373 @Nullable
374 public String getFocalLengthDescription()
375 {
376 Long value = _directory.getLongObject(CameraSettings.TAG_FOCAL_LENGTH);
377 return value == null ? null : getFocalLengthDescription(value/256d);
378 }
379
380 @Nullable
381 public String getFocusDistanceDescription()
382 {
383 Long value = _directory.getLongObject(CameraSettings.TAG_FOCUS_DISTANCE);
384 return value == null
385 ? null
386 : value == 0
387 ? "Infinity"
388 : value + " mm";
389 }
390
391 @Nullable
392 public String getFlashFiredDescription()
393 {
394 return getIndexedDescription(CameraSettings.TAG_FLASH_FIRED, "No", "Yes");
395 }
396
397 @Nullable
398 public String getDateDescription()
399 {
400 // day = value%256,
401 // month = floor( (value - floor( value/65536 )*65536 )/256 )
402 // year = floor( value/65536)
403 Long value = _directory.getLongObject(CameraSettings.TAG_DATE);
404 if (value == null)
405 return null;
406
407 int day = (int) (value & 0xFF);
408 int month = (int) ((value >> 16) & 0xFF);
409 int year = (int) ((value >> 8) & 0xFF) + 1970;
410
411 if (!DateUtil.isValidDate(year, month, day))
412 return "Invalid date";
413
414 return String.format("%04d-%02d-%02d", year, month + 1, day);
415 }
416
417 @Nullable
418 public String getTimeDescription()
419 {
420 // hours = floor( value/65536 ),
421 // minutes = floor( ( value - floor( value/65536 )*65536 )/256 ),
422 // seconds = value%256
423 Long value = _directory.getLongObject(CameraSettings.TAG_TIME);
424 if (value == null)
425 return null;
426
427 int hours = (int) ((value >> 8) & 0xFF);
428 int minutes = (int) ((value >> 16) & 0xFF);
429 int seconds = (int) (value & 0xFF);
430
431 if (!DateUtil.isValidTime(hours, minutes, seconds))
432 return "Invalid time";
433
434 return String.format("%02d:%02d:%02d", hours, minutes, seconds);
435 }
436
437 @Nullable
438 public String getMaxApertureAtFocalLengthDescription()
439 {
440 // Aperture F-Stop = 2^(value/16-0.5)
441 Long value = _directory.getLongObject(CameraSettings.TAG_TIME);
442 if (value == null)
443 return null;
444 double fStop = Math.pow((value/16d) - 0.5, 2);
445 return getFStopDescription(fStop);
446 }
447
448 @Nullable
449 public String getFileNumberMemoryDescription()
450 {
451 return getIndexedDescription(CameraSettings.TAG_FILE_NUMBER_MEMORY, "Off", "On");
452 }
453
454 @Nullable
455 public String getLastFileNumberDescription()
456 {
457 Long value = _directory.getLongObject(CameraSettings.TAG_LAST_FILE_NUMBER);
458 return value == null
459 ? null
460 : value == 0
461 ? "File Number Memory Off"
462 : Long.toString(value);
463 }
464
465 @Nullable
466 public String getWhiteBalanceRedDescription()
467 {
468 Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_RED);
469 DecimalFormat format = new DecimalFormat("0.##");
470 return value == null ? null : format.format(value/256d);
471 }
472
473 @Nullable
474 public String getWhiteBalanceGreenDescription()
475 {
476 Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_GREEN);
477 DecimalFormat format = new DecimalFormat("0.##");
478 return value == null ? null : format.format(value/256d);
479 }
480
481 @Nullable
482 public String getWhiteBalanceBlueDescription()
483 {
484 Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_BLUE);
485 DecimalFormat format = new DecimalFormat("0.##");
486 return value == null ? null : format.format(value / 256d);
487 }
488
489 @Nullable
490 public String getSaturationDescription()
491 {
492 Long value = _directory.getLongObject(CameraSettings.TAG_SATURATION);
493 return value == null ? null : Long.toString(value-3);
494 }
495
496 @Nullable
497 public String getContrastCameraSettingDescription()
498 {
499 Long value = _directory.getLongObject(CameraSettings.TAG_CONTRAST);
500 return value == null ? null : Long.toString(value-3);
501 }
502
503 @Nullable
504 public String getSharpnessCameraSettingDescription()
505 {
506 return getIndexedDescription(CameraSettings.TAG_SHARPNESS, "Hard", "Normal", "Soft");
507 }
508
509 @Nullable
510 public String getSubjectProgramDescription()
511 {
512 return getIndexedDescription(CameraSettings.TAG_SUBJECT_PROGRAM, "None", "Portrait", "Text", "Night Portrait", "Sunset", "Sports Action");
513 }
514
515 @Nullable
516 public String getFlashCompensationDescription()
517 {
518 Long value = _directory.getLongObject(CameraSettings.TAG_FLASH_COMPENSATION);
519 DecimalFormat format = new DecimalFormat("0.##");
520 return value == null ? null : format.format((value-6)/3d) + " EV";
521 }
522
523 @Nullable
524 public String getIsoSettingDescription()
525 {
526 return getIndexedDescription(CameraSettings.TAG_ISO_SETTING, "100", "200", "400", "800", "Auto", "64");
527 }
528
529 @Nullable
530 public String getCameraModelDescription()
531 {
532 return getIndexedDescription(CameraSettings.TAG_CAMERA_MODEL,
533 "DiMAGE 7",
534 "DiMAGE 5",
535 "DiMAGE S304",
536 "DiMAGE S404",
537 "DiMAGE 7i",
538 "DiMAGE 7Hi",
539 "DiMAGE A1",
540 "DiMAGE S414");
541 }
542
543 @Nullable
544 public String getIntervalModeDescription()
545 {
546 return getIndexedDescription(CameraSettings.TAG_INTERVAL_MODE, "Still Image", "Time Lapse Movie");
547 }
548
549 @Nullable
550 public String getFolderNameDescription()
551 {
552 return getIndexedDescription(CameraSettings.TAG_FOLDER_NAME, "Standard Form", "Data Form");
553 }
554
555 @Nullable
556 public String getColorModeCameraSettingDescription()
557 {
558 return getIndexedDescription(CameraSettings.TAG_COLOR_MODE, "Natural Color", "Black & White", "Vivid Color", "Solarization", "AdobeRGB");
559 }
560
561 @Nullable
562 public String getColorFilterDescription()
563 {
564 Long value = _directory.getLongObject(CameraSettings.TAG_COLOR_FILTER);
565 return value == null ? null : Long.toString(value-3);
566 }
567
568 @Nullable
569 public String getBlackAndWhiteFilterDescription()
570 {
571 return super.getDescription(CameraSettings.TAG_BLACK_AND_WHITE_FILTER);
572 }
573
574 @Nullable
575 public String getInternalFlashDescription()
576 {
577 return getIndexedDescription(CameraSettings.TAG_INTERNAL_FLASH, "Did Not Fire", "Fired");
578 }
579
580 @Nullable
581 public String getApexBrightnessDescription()
582 {
583 Long value = _directory.getLongObject(CameraSettings.TAG_APEX_BRIGHTNESS_VALUE);
584 DecimalFormat format = new DecimalFormat("0.##");
585 return value == null ? null : format.format((value/8d)-6);
586 }
587
588 @Nullable
589 public String getSpotFocusPointXCoordinateDescription()
590 {
591 return super.getDescription(CameraSettings.TAG_SPOT_FOCUS_POINT_X_COORDINATE);
592 }
593
594 @Nullable
595 public String getSpotFocusPointYCoordinateDescription()
596 {
597 return super.getDescription(CameraSettings.TAG_SPOT_FOCUS_POINT_Y_COORDINATE);
598 }
599
600 @Nullable
601 public String getWideFocusZoneDescription()
602 {
603 return getIndexedDescription(CameraSettings.TAG_WIDE_FOCUS_ZONE,
604 "No Zone or AF Failed",
605 "Center Zone (Horizontal Orientation)",
606 "Center Zone (Vertical Orientation)",
607 "Left Zone",
608 "Right Zone"
609 );
610 }
611
612 @Nullable
613 public String getFocusModeCameraSettingDescription()
614 {
615 return getIndexedDescription(CameraSettings.TAG_FOCUS_MODE, "Auto Focus", "Manual Focus");
616 }
617
618 @Nullable
619 public String getFocusAreaDescription()
620 {
621 return getIndexedDescription(CameraSettings.TAG_FOCUS_AREA, "Wide Focus (Normal)", "Spot Focus");
622 }
623
624 @Nullable
625 public String getDecSwitchPositionDescription()
626 {
627 return getIndexedDescription(CameraSettings.TAG_DEC_SWITCH_POSITION, "Exposure", "Contrast", "Saturation", "Filter");
628 }
629
630 @Nullable
631 public String getMakernoteVersionDescription()
632 {
633 return getVersionBytesDescription(TAG_MAKERNOTE_VERSION, 2);
634 }
635
636 @Nullable
637 public String getImageQuality2Description()
638 {
639 return getIndexedDescription(TAG_IMAGE_QUALITY_2,
640 "Raw",
641 "Super Fine",
642 "Fine",
643 "Standard",
644 "Extra Fine");
645 }
646
647 @Nullable
648 public String getImageQuality1Description()
649 {
650 return getIndexedDescription(TAG_IMAGE_QUALITY_1,
651 "Raw",
652 "Super Fine",
653 "Fine",
654 "Standard",
655 "Extra Fine");
656 }
657
658 @Nullable
659 public String getColorModeDescription()
660 {
661 return getIndexedDescription(TAG_COLOUR_MODE,
662 "Natural Colour",
663 "Black & White",
664 "Vivid Colour",
665 "Solarization",
666 "AdobeRGB");
667 }
668
669 @Nullable
670 public String getSharpnessDescription()
671 {
672 return getIndexedDescription(TAG_SHARPNESS, "Normal", "Hard", "Soft");
673 }
674
675 @Nullable
676 public String getColorMatrixDescription()
677 {
678 int[] obj = _directory.getIntArray(TAG_COLOUR_MATRIX);
679 if (obj == null)
680 return null;
681
682 StringBuilder sb = new StringBuilder();
683 for (int i = 0; i < obj.length; i++) {
684 sb.append((short)obj[i]);
685 if (i < obj.length - 1)
686 sb.append(" ");
687 }
688 return sb.length() == 0 ? null : sb.toString();
689 }
690
691 @Nullable
692 public String getWbModeDescription()
693 {
694 int[] obj = _directory.getIntArray(TAG_WB_MODE);
695 if (obj == null)
696 return null;
697
698 String val = String.format("%d %d", obj[0], obj[1]);
699
700 if(val.equals("1 0"))
701 return "Auto";
702 else if(val.equals("1 2"))
703 return "Auto (2)";
704 else if(val.equals("1 4"))
705 return "Auto (4)";
706 else if(val.equals("2 2"))
707 return "3000 Kelvin";
708 else if(val.equals("2 3"))
709 return "3700 Kelvin";
710 else if(val.equals("2 4"))
711 return "4000 Kelvin";
712 else if(val.equals("2 5"))
713 return "4500 Kelvin";
714 else if(val.equals("2 6"))
715 return "5500 Kelvin";
716 else if(val.equals("2 7"))
717 return "6500 Kelvin";
718 else if(val.equals("2 8"))
719 return "7500 Kelvin";
720 else if(val.equals("3 0"))
721 return "One-touch";
722 else
723 return "Unknown " + val;
724 }
725
726 @Nullable
727 public String getRedBalanceDescription()
728 {
729 int[] values = _directory.getIntArray(TAG_RED_BALANCE);
730 if (values == null)
731 return null;
732
733 short value = (short)values[0];
734
735 return String.valueOf((double)value/256d);
736 }
737
738 @Nullable
739 public String getBlueBalanceDescription()
740 {
741 int[] values = _directory.getIntArray(TAG_BLUE_BALANCE);
742 if (values == null)
743 return null;
744
745 short value = (short)values[0];
746
747 return String.valueOf((double)value/256d);
748 }
749
750 @Nullable
751 public String getContrastDescription()
752 {
753 return getIndexedDescription(TAG_CONTRAST, "High", "Normal", "Low");
754 }
755
756 @Nullable
757 public String getPreviewImageValidDescription()
758 {
759 return getIndexedDescription(TAG_PREVIEW_IMAGE_VALID, "No", "Yes");
760 }
761
762 @Nullable
763 public String getFocusModeDescription()
764 {
765 return getIndexedDescription(TAG_FOCUS_MODE, "Auto", "Manual");
766 }
767
768 @Nullable
769 public String getFocusRangeDescription()
770 {
771 return getIndexedDescription(TAG_FOCUS_RANGE, "Normal", "Macro");
772 }
773
774 @Nullable
775 public String getFlashModeDescription()
776 {
777 return getIndexedDescription(TAG_FLASH_MODE, null, null, "On", "Off");
778 }
779
780 @Nullable
781 public String getDigitalZoomDescription()
782 {
783 Rational value = _directory.getRational(TAG_DIGITAL_ZOOM);
784 if (value == null)
785 return null;
786 return value.toSimpleString(false);
787 }
788
789 @Nullable
790 public String getFocalPlaneDiagonalDescription()
791 {
792 Rational value = _directory.getRational(TAG_FOCAL_PLANE_DIAGONAL);
793 if (value == null)
794 return null;
795
796 DecimalFormat format = new DecimalFormat("0.###");
797 return format.format(value.doubleValue()) + " mm";
798 }
799
800 @Nullable
801 public String getCameraTypeDescription()
802 {
803 String cameratype = _directory.getString(TAG_CAMERA_TYPE);
804 if(cameratype == null)
805 return null;
806
807 if(OlympusMakernoteDirectory.OlympusCameraTypes.containsKey(cameratype))
808 return OlympusMakernoteDirectory.OlympusCameraTypes.get(cameratype);
809
810 return cameratype;
811 }
812
813 @Nullable
814 public String getCameraIdDescription()
815 {
816 byte[] bytes = _directory.getByteArray(TAG_CAMERA_ID);
817 if (bytes == null)
818 return null;
819 return new String(bytes);
820 }
821
822 @Nullable
823 public String getOneTouchWbDescription()
824 {
825 return getIndexedDescription(TAG_ONE_TOUCH_WB, "Off", "On", "On (Preset)");
826 }
827
828 @Nullable
829 public String getShutterSpeedDescription()
830 {
831 return super.getShutterSpeedDescription(TAG_SHUTTER_SPEED_VALUE);
832 }
833
834 @Nullable
835 public String getIsoValueDescription()
836 {
837 Rational value = _directory.getRational(TAG_ISO_VALUE);
838 if (value == null)
839 return null;
840
841 return String.valueOf(Math.round(Math.pow(2, value.doubleValue() - 5) * 100));
842 }
843
844 @Nullable
845 public String getApertureValueDescription()
846 {
847 Double aperture = _directory.getDoubleObject(TAG_APERTURE_VALUE);
848 if (aperture == null)
849 return null;
850 double fStop = PhotographicConversions.apertureToFStop(aperture);
851 return getFStopDescription(fStop);
852 }
853
854 @Nullable
855 public String getMacroModeDescription()
856 {
857 return getIndexedDescription(TAG_MACRO_MODE, "Normal (no macro)", "Macro");
858 }
859
860 @Nullable
861 public String getBWModeDescription()
862 {
863 return getIndexedDescription(TAG_BW_MODE, "Off", "On");
864 }
865
866 @Nullable
867 public String getJpegQualityDescription()
868 {
869 String cameratype = _directory.getString(TAG_CAMERA_TYPE);
870
871 if(cameratype != null)
872 {
873 Integer value = _directory.getInteger(TAG_JPEG_QUALITY);
874 if(value == null)
875 return null;
876
877 if((cameratype.startsWith("SX") && !cameratype.startsWith("SX151"))
878 || cameratype.startsWith("D4322"))
879 {
880 switch (value)
881 {
882 case 0:
883 return "Standard Quality (Low)";
884 case 1:
885 return "High Quality (Normal)";
886 case 2:
887 return "Super High Quality (Fine)";
888 case 6:
889 return "RAW";
890 default:
891 return "Unknown (" + value.toString() + ")";
892 }
893 }
894 else
895 {
896 switch (value)
897 {
898 case 0:
899 return "Standard Quality (Low)";
900 case 1:
901 return "High Quality (Normal)";
902 case 2:
903 return "Super High Quality (Fine)";
904 case 4:
905 return "RAW";
906 case 5:
907 return "Medium-Fine";
908 case 6:
909 return "Small-Fine";
910 case 33:
911 return "Uncompressed";
912 default:
913 return "Unknown (" + value.toString() + ")";
914 }
915 }
916 }
917 else
918 return getIndexedDescription(TAG_JPEG_QUALITY,
919 1,
920 "Standard Quality",
921 "High Quality",
922 "Super High Quality");
923 }
924
925 @Nullable
926 public String getSpecialModeDescription()
927 {
928 long[] values = (long[])_directory.getObject(TAG_SPECIAL_MODE);
929 if (values==null)
930 return null;
931 if (values.length < 1)
932 return "";
933 StringBuilder desc = new StringBuilder();
934
935 switch ((int)values[0]) {
936 case 0:
937 desc.append("Normal picture taking mode");
938 break;
939 case 1:
940 desc.append("Unknown picture taking mode");
941 break;
942 case 2:
943 desc.append("Fast picture taking mode");
944 break;
945 case 3:
946 desc.append("Panorama picture taking mode");
947 break;
948 default:
949 desc.append("Unknown picture taking mode");
950 break;
951 }
952
953 if (values.length >= 2) {
954 switch ((int)values[1]) {
955 case 0:
956 break;
957 case 1:
958 desc.append(" / 1st in a sequence");
959 break;
960 case 2:
961 desc.append(" / 2nd in a sequence");
962 break;
963 case 3:
964 desc.append(" / 3rd in a sequence");
965 break;
966 default:
967 desc.append(" / ");
968 desc.append(values[1]);
969 desc.append("th in a sequence");
970 break;
971 }
972 }
973 if (values.length >= 3) {
974 switch ((int)values[2]) {
975 case 1:
976 desc.append(" / Left to right panorama direction");
977 break;
978 case 2:
979 desc.append(" / Right to left panorama direction");
980 break;
981 case 3:
982 desc.append(" / Bottom to top panorama direction");
983 break;
984 case 4:
985 desc.append(" / Top to bottom panorama direction");
986 break;
987 }
988 }
989
990 return desc.toString();
991 }
992}
Note: See TracBrowser for help on using the repository browser.