[13061] | 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 static com.drew.metadata.exif.makernotes.OlympusRawInfoMakernoteDirectory.*;
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * Provides human-readable String representations of tag values stored in a {@link OlympusRawInfoMakernoteDirectory}.
|
---|
| 32 | * <p>
|
---|
| 33 | * Some Description functions converted from Exiftool version 10.33 created by Phil Harvey
|
---|
| 34 | * http://www.sno.phy.queensu.ca/~phil/exiftool/
|
---|
| 35 | * lib\Image\ExifTool\Olympus.pm
|
---|
| 36 | *
|
---|
| 37 | * @author Kevin Mott https://github.com/kwhopper
|
---|
| 38 | * @author Drew Noakes https://drewnoakes.com
|
---|
| 39 | */
|
---|
| 40 | @SuppressWarnings("WeakerAccess")
|
---|
| 41 | public class OlympusRawInfoMakernoteDescriptor extends TagDescriptor<OlympusRawInfoMakernoteDirectory>
|
---|
| 42 | {
|
---|
| 43 | public OlympusRawInfoMakernoteDescriptor(@NotNull OlympusRawInfoMakernoteDirectory directory)
|
---|
| 44 | {
|
---|
| 45 | super(directory);
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | @Override
|
---|
| 49 | @Nullable
|
---|
| 50 | public String getDescription(int tagType)
|
---|
| 51 | {
|
---|
| 52 | switch (tagType) {
|
---|
| 53 | case TagRawInfoVersion:
|
---|
| 54 | return getVersionBytesDescription(TagRawInfoVersion, 4);
|
---|
| 55 | case TagColorMatrix2:
|
---|
| 56 | return getColorMatrix2Description();
|
---|
| 57 | case TagYCbCrCoefficients:
|
---|
| 58 | return getYCbCrCoefficientsDescription();
|
---|
| 59 | case TagLightSource:
|
---|
| 60 | return getOlympusLightSourceDescription();
|
---|
| 61 | default:
|
---|
| 62 | return super.getDescription(tagType);
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | @Nullable
|
---|
| 67 | public String getColorMatrix2Description()
|
---|
| 68 | {
|
---|
| 69 | int[] values = _directory.getIntArray(TagColorMatrix2);
|
---|
| 70 | if (values == null)
|
---|
| 71 | return null;
|
---|
| 72 |
|
---|
| 73 | StringBuilder sb = new StringBuilder();
|
---|
| 74 | for (int i = 0; i < values.length; i++) {
|
---|
| 75 | sb.append((short)values[i]);
|
---|
| 76 | if (i < values.length - 1)
|
---|
| 77 | sb.append(" ");
|
---|
| 78 | }
|
---|
| 79 | return sb.length() == 0 ? null : sb.toString();
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | @Nullable
|
---|
| 83 | public String getYCbCrCoefficientsDescription()
|
---|
| 84 | {
|
---|
| 85 | int[] values = _directory.getIntArray(TagYCbCrCoefficients);
|
---|
| 86 | if (values == null)
|
---|
| 87 | return null;
|
---|
| 88 |
|
---|
| 89 | Rational[] ret = new Rational[values.length / 2];
|
---|
| 90 | for(int i = 0; i < values.length / 2; i++)
|
---|
| 91 | {
|
---|
| 92 | ret[i] = new Rational((short)values[2*i], (short)values[2*i + 1]);
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | StringBuilder sb = new StringBuilder();
|
---|
| 96 | for (int i = 0; i < ret.length; i++) {
|
---|
| 97 | sb.append(ret[i].doubleValue());
|
---|
| 98 | if (i < ret.length - 1)
|
---|
| 99 | sb.append(" ");
|
---|
| 100 | }
|
---|
| 101 | return sb.length() == 0 ? null : sb.toString();
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | @Nullable
|
---|
| 105 | public String getOlympusLightSourceDescription()
|
---|
| 106 | {
|
---|
| 107 | Integer value = _directory.getInteger(TagLightSource);
|
---|
| 108 | if (value == null)
|
---|
| 109 | return null;
|
---|
| 110 |
|
---|
| 111 | switch (value.shortValue())
|
---|
| 112 | {
|
---|
| 113 | case 0:
|
---|
| 114 | return "Unknown";
|
---|
| 115 | case 16:
|
---|
| 116 | return "Shade";
|
---|
| 117 | case 17:
|
---|
| 118 | return "Cloudy";
|
---|
| 119 | case 18:
|
---|
| 120 | return "Fine Weather";
|
---|
| 121 | case 20:
|
---|
| 122 | return "Tungsten (Incandescent)";
|
---|
| 123 | case 22:
|
---|
| 124 | return "Evening Sunlight";
|
---|
| 125 | case 33:
|
---|
| 126 | return "Daylight Fluorescent";
|
---|
| 127 | case 34:
|
---|
| 128 | return "Day White Fluorescent";
|
---|
| 129 | case 35:
|
---|
| 130 | return "Cool White Fluorescent";
|
---|
| 131 | case 36:
|
---|
| 132 | return "White Fluorescent";
|
---|
| 133 | case 256:
|
---|
| 134 | return "One Touch White Balance";
|
---|
| 135 | case 512:
|
---|
| 136 | return "Custom 1-4";
|
---|
| 137 | default:
|
---|
| 138 | return "Unknown (" + value + ")";
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 | }
|
---|