| 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 | */
|
|---|
| 21 |
|
|---|
| 22 | package com.drew.metadata.exif;
|
|---|
| 23 |
|
|---|
| 24 | import com.drew.lang.Rational;
|
|---|
| 25 | import com.drew.lang.annotations.NotNull;
|
|---|
| 26 | import com.drew.lang.annotations.Nullable;
|
|---|
| 27 | import com.drew.metadata.TagDescriptor;
|
|---|
| 28 |
|
|---|
| 29 | import static com.drew.metadata.exif.PanasonicRawDistortionDirectory.*;
|
|---|
| 30 |
|
|---|
| 31 | /**
|
|---|
| 32 | * Provides human-readable string representations of tag values stored in a {@link PanasonicRawDistortionDirectory}.
|
|---|
| 33 | *
|
|---|
| 34 | * @author Kevin Mott https://github.com/kwhopper
|
|---|
| 35 | * @author Drew Noakes https://drewnoakes.com
|
|---|
| 36 | */
|
|---|
| 37 | @SuppressWarnings("WeakerAccess")
|
|---|
| 38 | public class PanasonicRawDistortionDescriptor extends TagDescriptor<PanasonicRawDistortionDirectory>
|
|---|
| 39 | {
|
|---|
| 40 | public PanasonicRawDistortionDescriptor(@NotNull PanasonicRawDistortionDirectory directory)
|
|---|
| 41 | {
|
|---|
| 42 | super(directory);
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | @Override
|
|---|
| 46 | @Nullable
|
|---|
| 47 | public String getDescription(int tagType)
|
|---|
| 48 | {
|
|---|
| 49 | switch (tagType) {
|
|---|
| 50 | case TagDistortionParam02:
|
|---|
| 51 | return getDistortionParam02Description();
|
|---|
| 52 | case TagDistortionParam04:
|
|---|
| 53 | return getDistortionParam04Description();
|
|---|
| 54 | case TagDistortionScale:
|
|---|
| 55 | return getDistortionScaleDescription();
|
|---|
| 56 | case TagDistortionCorrection:
|
|---|
| 57 | return getDistortionCorrectionDescription();
|
|---|
| 58 | case TagDistortionParam08:
|
|---|
| 59 | return getDistortionParam08Description();
|
|---|
| 60 | case TagDistortionParam09:
|
|---|
| 61 | return getDistortionParam09Description();
|
|---|
| 62 | case TagDistortionParam11:
|
|---|
| 63 | return getDistortionParam11Description();
|
|---|
| 64 | default:
|
|---|
| 65 | return super.getDescription(tagType);
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | @Nullable
|
|---|
| 70 | public String getWbTypeDescription(int tagType)
|
|---|
| 71 | {
|
|---|
| 72 | Integer wbtype = _directory.getInteger(tagType);
|
|---|
| 73 | if (wbtype == null)
|
|---|
| 74 | return null;
|
|---|
| 75 |
|
|---|
| 76 | return super.getLightSourceDescription(wbtype.shortValue());
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | @Nullable
|
|---|
| 80 | public String getDistortionParam02Description()
|
|---|
| 81 | {
|
|---|
| 82 | Integer value = _directory.getInteger(TagDistortionParam02);
|
|---|
| 83 | if (value == null)
|
|---|
| 84 | return null;
|
|---|
| 85 |
|
|---|
| 86 | return new Rational(value, 32678).toString();
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | @Nullable
|
|---|
| 90 | public String getDistortionParam04Description()
|
|---|
| 91 | {
|
|---|
| 92 | Integer value = _directory.getInteger(TagDistortionParam04);
|
|---|
| 93 | if (value == null)
|
|---|
| 94 | return null;
|
|---|
| 95 |
|
|---|
| 96 | return new Rational(value, 32678).toString();
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | @Nullable
|
|---|
| 100 | public String getDistortionScaleDescription()
|
|---|
| 101 | {
|
|---|
| 102 | Integer value = _directory.getInteger(TagDistortionScale);
|
|---|
| 103 | if (value == null)
|
|---|
| 104 | return null;
|
|---|
| 105 |
|
|---|
| 106 | //return (1 / (1 + value / 32768)).toString();
|
|---|
| 107 | return Integer.toString(1 / (1 + value / 32768));
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | @Nullable
|
|---|
| 111 | public String getDistortionCorrectionDescription()
|
|---|
| 112 | {
|
|---|
| 113 | Integer value = _directory.getInteger(TagDistortionCorrection);
|
|---|
| 114 | if (value == null)
|
|---|
| 115 | return null;
|
|---|
| 116 |
|
|---|
| 117 | // (have seen the upper 4 bits set for GF5 and GX1, giving a value of -4095 - PH)
|
|---|
| 118 | int mask = 0x000f;
|
|---|
| 119 | switch (value & mask)
|
|---|
| 120 | {
|
|---|
| 121 | case 0:
|
|---|
| 122 | return "Off";
|
|---|
| 123 | case 1:
|
|---|
| 124 | return "On";
|
|---|
| 125 | default:
|
|---|
| 126 | return "Unknown (" + value + ")";
|
|---|
| 127 | }
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | @Nullable
|
|---|
| 131 | public String getDistortionParam08Description()
|
|---|
| 132 | {
|
|---|
| 133 | Integer value = _directory.getInteger(TagDistortionParam08);
|
|---|
| 134 | if (value == null)
|
|---|
| 135 | return null;
|
|---|
| 136 |
|
|---|
| 137 | return new Rational(value, 32678).toString();
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | @Nullable
|
|---|
| 141 | public String getDistortionParam09Description()
|
|---|
| 142 | {
|
|---|
| 143 | Integer value = _directory.getInteger(TagDistortionParam09);
|
|---|
| 144 | if (value == null)
|
|---|
| 145 | return null;
|
|---|
| 146 |
|
|---|
| 147 | return new Rational(value, 32678).toString();
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | @Nullable
|
|---|
| 151 | public String getDistortionParam11Description()
|
|---|
| 152 | {
|
|---|
| 153 | Integer value = _directory.getInteger(TagDistortionParam11);
|
|---|
| 154 | if (value == null)
|
|---|
| 155 | return null;
|
|---|
| 156 |
|
|---|
| 157 | return new Rational(value, 32678).toString();
|
|---|
| 158 | }
|
|---|
| 159 | }
|
|---|