Ignore:
Timestamp:
2016-08-20T20:58:03+02:00 (8 years ago)
Author:
Don-vip
Message:

update to metadata-extractor 2.9.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/metadata/exif/makernotes/OlympusMakernoteDescriptor.java

    r8132 r10862  
    11/*
    2  * Copyright 2002-2015 Drew Noakes
     2 * Copyright 2002-2016 Drew Noakes
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    2121package com.drew.metadata.exif.makernotes;
    2222
     23import com.drew.lang.DateUtil;
    2324import com.drew.lang.annotations.NotNull;
    2425import com.drew.lang.annotations.Nullable;
    2526import com.drew.metadata.TagDescriptor;
    2627
    27 import java.util.GregorianCalendar;
     28import java.math.RoundingMode;
     29import java.text.DecimalFormat;
    2830
    2931import static com.drew.metadata.exif.makernotes.OlympusMakernoteDirectory.*;
     
    115117                return getFocusDistanceDescription();
    116118            case CameraSettings.TAG_FLASH_FIRED:
    117                 return getFlastFiredDescription();
     119                return getFlashFiredDescription();
    118120            case CameraSettings.TAG_DATE:
    119121                return getDateDescription();
     
    142144                return getSubjectProgramDescription();
    143145            case CameraSettings.TAG_FLASH_COMPENSATION:
    144                 return getFlastCompensationDescription();
     146                return getFlashCompensationDescription();
    145147            case CameraSettings.TAG_ISO_SETTING:
    146148                return getIsoSettingDescription();
     
    258260
    259261        double iso = Math.pow((value / 8d) - 1, 2) * 3.125;
    260         return Double.toString(iso);
     262        DecimalFormat format = new DecimalFormat("0.##");
     263        format.setRoundingMode(RoundingMode.HALF_UP);
     264        return format.format(iso);
    261265    }
    262266
     
    274278
    275279        double shutterSpeed = Math.pow((49-value) / 8d, 2);
    276         return Double.toString(shutterSpeed) + " sec";
     280        DecimalFormat format = new DecimalFormat("0.###");
     281        format.setRoundingMode(RoundingMode.HALF_UP);
     282        return format.format(shutterSpeed) + " sec";
    277283    }
    278284
     
    289295
    290296        double fStop = Math.pow((value/16d) - 0.5, 2);
    291         return "F" + Double.toString(fStop);
     297        return getFStopDescription(fStop);
    292298    }
    293299
     
    308314    {
    309315        Long value = _directory.getLongObject(CameraSettings.TAG_EXPOSURE_COMPENSATION);
    310         return value == null ? null : ((value / 3d) - 2) + " EV";
     316        DecimalFormat format = new DecimalFormat("0.##");
     317        return value == null ? null : format.format((value / 3d) - 2) + " EV";
    311318    }
    312319
     
    341348    {
    342349        Long value = _directory.getLongObject(CameraSettings.TAG_FOCAL_LENGTH);
    343         return value == null ? null : Double.toString(value/256d) + " mm";
     350        return value == null ? null : getFocalLengthDescription(value/256d);
    344351    }
    345352
     
    356363
    357364    @Nullable
    358     public String getFlastFiredDescription()
     365    public String getFlashFiredDescription()
    359366    {
    360367        return getIndexedDescription(CameraSettings.TAG_FLASH_FIRED, "No", "Yes");
     
    370377        if (value == null)
    371378            return null;
    372         long day = value & 0xFF;
    373         long month = (value >> 16) & 0xFF;
    374         long year = (value >> 8) & 0xFF;
    375         return new GregorianCalendar((int)year + 1970, (int)month, (int)day).getTime().toString();
     379
     380        int day = (int) (value & 0xFF);
     381        int month = (int) ((value >> 16) & 0xFF);
     382        int year = (int) ((value >> 8) & 0xFF) + 1970;
     383
     384        if (!DateUtil.isValidDate(year, month, day))
     385            return "Invalid date";
     386
     387        return String.format("%04d-%02d-%02d", year, month + 1, day);
    376388    }
    377389
     
    385397        if (value == null)
    386398            return null;
    387         long hours = (value >> 8) & 0xFF;
    388         long minutes = (value >> 16) & 0xFF;
    389         long seconds = value & 0xFF;
     399
     400        int hours = (int) ((value >> 8) & 0xFF);
     401        int minutes = (int) ((value >> 16) & 0xFF);
     402        int seconds = (int) (value & 0xFF);
     403
     404        if (!DateUtil.isValidTime(hours, minutes, seconds))
     405            return "Invalid time";
    390406
    391407        return String.format("%02d:%02d:%02d", hours, minutes, seconds);
     
    400416            return null;
    401417        double fStop = Math.pow((value/16d) - 0.5, 2);
    402         return "F" + fStop;
     418        return getFStopDescription(fStop);
    403419    }
    404420
     
    424440    {
    425441        Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_RED);
    426         return value == null ? null : Double.toString(value/256d);
     442        DecimalFormat format = new DecimalFormat("0.##");
     443        return value == null ? null : format.format(value/256d);
    427444    }
    428445
     
    431448    {
    432449        Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_GREEN);
    433         return value == null ? null : Double.toString(value/256d);
     450        DecimalFormat format = new DecimalFormat("0.##");
     451        return value == null ? null : format.format(value/256d);
    434452    }
    435453
     
    438456    {
    439457        Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_BLUE);
    440         return value == null ? null : Double.toString(value/256d);
     458        DecimalFormat format = new DecimalFormat("0.##");
     459        return value == null ? null : format.format(value / 256d);
    441460    }
    442461
     
    468487
    469488    @Nullable
    470     public String getFlastCompensationDescription()
     489    public String getFlashCompensationDescription()
    471490    {
    472491        Long value = _directory.getLongObject(CameraSettings.TAG_FLASH_COMPENSATION);
    473         return value == null ? null : ((value-6)/3d) + " EV";
     492        DecimalFormat format = new DecimalFormat("0.##");
     493        return value == null ? null : format.format((value-6)/3d) + " EV";
    474494    }
    475495
     
    535555    {
    536556        Long value = _directory.getLongObject(CameraSettings.TAG_APEX_BRIGHTNESS_VALUE);
    537         return value == null ? null : Double.toString((value/8d)-6);
     557        DecimalFormat format = new DecimalFormat("0.##");
     558        return value == null ? null : format.format((value/8d)-6);
    538559    }
    539560
Note: See TracChangeset for help on using the changeset viewer.