1 | /*
|
---|
2 | * Copyright 2002-2012 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 | * http://drewnoakes.com/code/exif/
|
---|
19 | * http://code.google.com/p/metadata-extractor/
|
---|
20 | */
|
---|
21 | package com.drew.metadata.exif;
|
---|
22 |
|
---|
23 | import com.drew.lang.annotations.NotNull;
|
---|
24 | import com.drew.lang.annotations.Nullable;
|
---|
25 | import com.drew.metadata.TagDescriptor;
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Provides human-readable string representations of tag values stored in a <code>SonyType1MakernoteDirectory</code>.
|
---|
29 | * Thanks to David Carson for the initial version of this class.
|
---|
30 | *
|
---|
31 | * @author Drew Noakes http://drewnoakes.com
|
---|
32 | */
|
---|
33 | public class SonyType1MakernoteDescriptor extends TagDescriptor<SonyType1MakernoteDirectory>
|
---|
34 | {
|
---|
35 | public SonyType1MakernoteDescriptor(@NotNull SonyType1MakernoteDirectory directory)
|
---|
36 | {
|
---|
37 | super(directory);
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Nullable
|
---|
41 | public String getDescription(int tagType)
|
---|
42 | {
|
---|
43 | switch (tagType) {
|
---|
44 | case SonyType1MakernoteDirectory.TAG_COLOR_TEMPERATURE:
|
---|
45 | return getColorTemperatureDescription();
|
---|
46 | case SonyType1MakernoteDirectory.TAG_SCENE_MODE:
|
---|
47 | return getSceneModeDescription();
|
---|
48 | case SonyType1MakernoteDirectory.TAG_ZONE_MATCHING:
|
---|
49 | return getZoneMatchingDescription();
|
---|
50 | case SonyType1MakernoteDirectory.TAG_DYNAMIC_RANGE_OPTIMISER:
|
---|
51 | return getDynamicRangeOptimizerDescription();
|
---|
52 | case SonyType1MakernoteDirectory.TAG_IMAGE_STABILISATION:
|
---|
53 | return getImageStabilizationDescription();
|
---|
54 | // Unfortunately it seems that there is no definite mapping between a lens ID and a lens model
|
---|
55 | // http://gvsoft.homedns.org/exif/makernote-sony-type1.html#0xb027
|
---|
56 | // case SonyType1MakernoteDirectory.TAG_LENS_ID:
|
---|
57 | // return getLensIDDescription();
|
---|
58 | case SonyType1MakernoteDirectory.TAG_COLOR_MODE:
|
---|
59 | return getColorModeDescription();
|
---|
60 | case SonyType1MakernoteDirectory.TAG_MACRO:
|
---|
61 | return getMacroDescription();
|
---|
62 | case SonyType1MakernoteDirectory.TAG_EXPOSURE_MODE:
|
---|
63 | return getExposureModeDescription();
|
---|
64 | case SonyType1MakernoteDirectory.TAG_QUALITY:
|
---|
65 | return getQualityDescription();
|
---|
66 | case SonyType1MakernoteDirectory.TAG_ANTI_BLUR:
|
---|
67 | return getAntiBlurDescription();
|
---|
68 | case SonyType1MakernoteDirectory.TAG_LONG_EXPOSURE_NOISE_REDUCTION:
|
---|
69 | return getLongExposureNoiseReductionDescription();
|
---|
70 | default:
|
---|
71 | return super.getDescription(tagType);
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | @Nullable
|
---|
76 | public String getColorTemperatureDescription()
|
---|
77 | {
|
---|
78 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_COLOR_TEMPERATURE);
|
---|
79 | if (value==null)
|
---|
80 | return null;
|
---|
81 | if (value==0)
|
---|
82 | return "Auto";
|
---|
83 | int kelvin = ((value & 0x00FF0000) >> 8) | ((value & 0xFF000000) >> 24);
|
---|
84 | return String.format("%d K", kelvin);
|
---|
85 | }
|
---|
86 |
|
---|
87 | @Nullable
|
---|
88 | public String getSceneModeDescription()
|
---|
89 | {
|
---|
90 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_SCENE_MODE);
|
---|
91 | if (value==null)
|
---|
92 | return null;
|
---|
93 | switch (value){
|
---|
94 | case 0: return "Standard";
|
---|
95 | case 1: return "Portrait";
|
---|
96 | case 2: return "Text";
|
---|
97 | case 3: return "Night Scene";
|
---|
98 | case 4: return "Sunset";
|
---|
99 | case 5: return "Sports";
|
---|
100 | case 6: return "Landscape";
|
---|
101 | case 7: return "Night Portrait";
|
---|
102 | case 8: return "Macro";
|
---|
103 | case 9: return "Super Macro";
|
---|
104 | case 16: return "Auto";
|
---|
105 | case 17: return "Night View/Portrait";
|
---|
106 | default: return String.format("Unknown (%d)", value);
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | @Nullable
|
---|
111 | public String getZoneMatchingDescription()
|
---|
112 | {
|
---|
113 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_ZONE_MATCHING);
|
---|
114 | if (value==null)
|
---|
115 | return null;
|
---|
116 | switch (value){
|
---|
117 | case 0: return "ISO Setting Used";
|
---|
118 | case 1: return "High Key";
|
---|
119 | case 2: return "Low Key";
|
---|
120 | default: return String.format("Unknown (%d)", value);
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | @Nullable
|
---|
125 | public String getDynamicRangeOptimizerDescription()
|
---|
126 | {
|
---|
127 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_DYNAMIC_RANGE_OPTIMISER);
|
---|
128 | if (value==null)
|
---|
129 | return null;
|
---|
130 | switch (value){
|
---|
131 | case 0: return "Off";
|
---|
132 | case 1: return "Standard";
|
---|
133 | case 2: return "Advanced Auto";
|
---|
134 | case 8: return "Advanced LV1";
|
---|
135 | case 9: return "Advanced LV2";
|
---|
136 | case 10: return "Advanced LV3";
|
---|
137 | case 11: return "Advanced LV4";
|
---|
138 | case 12: return "Advanced LV5";
|
---|
139 | default: return String.format("Unknown (%d)", value);
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | @Nullable
|
---|
144 | public String getImageStabilizationDescription()
|
---|
145 | {
|
---|
146 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_IMAGE_STABILISATION);
|
---|
147 | if (value==null)
|
---|
148 | return null;
|
---|
149 | // Different non-zero 'on' values have been observed. Do they mean different things?
|
---|
150 | return value == 0 ? "Off" : "On";
|
---|
151 | }
|
---|
152 |
|
---|
153 | @Nullable
|
---|
154 | public String getColorModeDescription()
|
---|
155 | {
|
---|
156 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_COLOR_MODE);
|
---|
157 | if (value==null)
|
---|
158 | return null;
|
---|
159 | switch (value){
|
---|
160 | case 0: return "Standard";
|
---|
161 | case 1: return "Vivid";
|
---|
162 | case 2: return "Portrait";
|
---|
163 | case 3: return "Landscape";
|
---|
164 | case 4: return "Sunset";
|
---|
165 | case 5: return "Night Portrait";
|
---|
166 | case 6: return "Black & White";
|
---|
167 | case 7: return "Adobe RGB";
|
---|
168 | case 12:
|
---|
169 | case 100: return "Neutral";
|
---|
170 | case 101: return "Clear";
|
---|
171 | case 102: return "Deep";
|
---|
172 | case 103: return "Light";
|
---|
173 | case 104: return "Night View";
|
---|
174 | case 105: return "Autumn Leaves";
|
---|
175 | default: return String.format("Unknown (%d)", value);
|
---|
176 | }
|
---|
177 | }
|
---|
178 |
|
---|
179 | @Nullable
|
---|
180 | public String getMacroDescription()
|
---|
181 | {
|
---|
182 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_MACRO);
|
---|
183 | if (value==null)
|
---|
184 | return null;
|
---|
185 | switch (value){
|
---|
186 | case 0: return "Off";
|
---|
187 | case 1: return "On";
|
---|
188 | case 2: return "Magnifying Glass/Super Macro";
|
---|
189 | case 0xFFFF: return "N/A";
|
---|
190 | default: return String.format("Unknown (%d)", value);
|
---|
191 | }
|
---|
192 | }
|
---|
193 |
|
---|
194 | @Nullable
|
---|
195 | public String getExposureModeDescription()
|
---|
196 | {
|
---|
197 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_EXPOSURE_MODE);
|
---|
198 | if (value==null)
|
---|
199 | return null;
|
---|
200 | switch (value){
|
---|
201 | case 0: return "Auto";
|
---|
202 | case 5: return "Landscape";
|
---|
203 | case 6: return "Program";
|
---|
204 | case 7: return "Aperture Priority";
|
---|
205 | case 8: return "Shutter Priority";
|
---|
206 | case 9: return "Night Scene";
|
---|
207 | case 15: return "Manual";
|
---|
208 | case 0xFFFF: return "N/A";
|
---|
209 | default: return String.format("Unknown (%d)", value);
|
---|
210 | }
|
---|
211 | }
|
---|
212 |
|
---|
213 | @Nullable
|
---|
214 | public String getQualityDescription()
|
---|
215 | {
|
---|
216 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_QUALITY);
|
---|
217 | if (value==null)
|
---|
218 | return null;
|
---|
219 | switch (value){
|
---|
220 | case 0: return "Normal";
|
---|
221 | case 1: return "Fine";
|
---|
222 | case 0xFFFF: return "N/A";
|
---|
223 | default: return String.format("Unknown (%d)", value);
|
---|
224 | }
|
---|
225 | }
|
---|
226 |
|
---|
227 | @Nullable
|
---|
228 | public String getAntiBlurDescription()
|
---|
229 | {
|
---|
230 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_ANTI_BLUR);
|
---|
231 | if (value==null)
|
---|
232 | return null;
|
---|
233 | switch (value){
|
---|
234 | case 0: return "Off";
|
---|
235 | case 1: return "On (Continuous)";
|
---|
236 | case 2: return "On (Shooting)";
|
---|
237 | case 0xFFFF: return "N/A";
|
---|
238 | default: return String.format("Unknown (%d)", value);
|
---|
239 | }
|
---|
240 | }
|
---|
241 |
|
---|
242 | @Nullable
|
---|
243 | public String getLongExposureNoiseReductionDescription()
|
---|
244 | {
|
---|
245 | Integer value = _directory.getInteger(SonyType1MakernoteDirectory.TAG_LONG_EXPOSURE_NOISE_REDUCTION);
|
---|
246 | if (value==null)
|
---|
247 | return null;
|
---|
248 | switch (value){
|
---|
249 | case 0: return "Off";
|
---|
250 | case 1: return "On";
|
---|
251 | case 0xFFFF: return "N/A";
|
---|
252 | default: return String.format("Unknown (%d)", value);
|
---|
253 | }
|
---|
254 | }
|
---|
255 | }
|
---|