[8132] | 1 | /*
|
---|
[13061] | 2 | * Copyright 2002-2017 Drew Noakes
|
---|
[8132] | 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.annotations.NotNull;
|
---|
| 24 | import com.drew.lang.annotations.Nullable;
|
---|
| 25 | import com.drew.metadata.TagDescriptor;
|
---|
| 26 |
|
---|
| 27 | import static com.drew.metadata.exif.makernotes.CasioType2MakernoteDirectory.*;
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * Provides human-readable string representations of tag values stored in a {@link CasioType2MakernoteDirectory}.
|
---|
| 31 | *
|
---|
| 32 | * @author Drew Noakes https://drewnoakes.com
|
---|
| 33 | */
|
---|
[13061] | 34 | @SuppressWarnings("WeakerAccess")
|
---|
[8132] | 35 | public class CasioType2MakernoteDescriptor extends TagDescriptor<CasioType2MakernoteDirectory>
|
---|
| 36 | {
|
---|
| 37 | public CasioType2MakernoteDescriptor(@NotNull CasioType2MakernoteDirectory directory)
|
---|
| 38 | {
|
---|
| 39 | super(directory);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | @Override
|
---|
| 43 | @Nullable
|
---|
| 44 | public String getDescription(int tagType)
|
---|
| 45 | {
|
---|
| 46 | switch (tagType) {
|
---|
| 47 | case TAG_THUMBNAIL_DIMENSIONS:
|
---|
| 48 | return getThumbnailDimensionsDescription();
|
---|
| 49 | case TAG_THUMBNAIL_SIZE:
|
---|
| 50 | return getThumbnailSizeDescription();
|
---|
| 51 | case TAG_THUMBNAIL_OFFSET:
|
---|
| 52 | return getThumbnailOffsetDescription();
|
---|
| 53 | case TAG_QUALITY_MODE:
|
---|
| 54 | return getQualityModeDescription();
|
---|
| 55 | case TAG_IMAGE_SIZE:
|
---|
| 56 | return getImageSizeDescription();
|
---|
| 57 | case TAG_FOCUS_MODE_1:
|
---|
| 58 | return getFocusMode1Description();
|
---|
| 59 | case TAG_ISO_SENSITIVITY:
|
---|
| 60 | return getIsoSensitivityDescription();
|
---|
| 61 | case TAG_WHITE_BALANCE_1:
|
---|
| 62 | return getWhiteBalance1Description();
|
---|
| 63 | case TAG_FOCAL_LENGTH:
|
---|
| 64 | return getFocalLengthDescription();
|
---|
| 65 | case TAG_SATURATION:
|
---|
| 66 | return getSaturationDescription();
|
---|
| 67 | case TAG_CONTRAST:
|
---|
| 68 | return getContrastDescription();
|
---|
| 69 | case TAG_SHARPNESS:
|
---|
| 70 | return getSharpnessDescription();
|
---|
| 71 | case TAG_PREVIEW_THUMBNAIL:
|
---|
| 72 | return getCasioPreviewThumbnailDescription();
|
---|
| 73 | case TAG_WHITE_BALANCE_BIAS:
|
---|
| 74 | return getWhiteBalanceBiasDescription();
|
---|
| 75 | case TAG_WHITE_BALANCE_2:
|
---|
| 76 | return getWhiteBalance2Description();
|
---|
| 77 | case TAG_OBJECT_DISTANCE:
|
---|
| 78 | return getObjectDistanceDescription();
|
---|
| 79 | case TAG_FLASH_DISTANCE:
|
---|
| 80 | return getFlashDistanceDescription();
|
---|
| 81 | case TAG_RECORD_MODE:
|
---|
| 82 | return getRecordModeDescription();
|
---|
| 83 | case TAG_SELF_TIMER:
|
---|
| 84 | return getSelfTimerDescription();
|
---|
| 85 | case TAG_QUALITY:
|
---|
| 86 | return getQualityDescription();
|
---|
| 87 | case TAG_FOCUS_MODE_2:
|
---|
| 88 | return getFocusMode2Description();
|
---|
| 89 | case TAG_TIME_ZONE:
|
---|
| 90 | return getTimeZoneDescription();
|
---|
| 91 | case TAG_CCD_ISO_SENSITIVITY:
|
---|
| 92 | return getCcdIsoSensitivityDescription();
|
---|
| 93 | case TAG_COLOUR_MODE:
|
---|
| 94 | return getColourModeDescription();
|
---|
| 95 | case TAG_ENHANCEMENT:
|
---|
| 96 | return getEnhancementDescription();
|
---|
| 97 | case TAG_FILTER:
|
---|
| 98 | return getFilterDescription();
|
---|
| 99 | default:
|
---|
| 100 | return super.getDescription(tagType);
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | @Nullable
|
---|
| 105 | public String getFilterDescription()
|
---|
| 106 | {
|
---|
| 107 | return getIndexedDescription(TAG_FILTER, "Off");
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | @Nullable
|
---|
| 111 | public String getEnhancementDescription()
|
---|
| 112 | {
|
---|
| 113 | return getIndexedDescription(TAG_ENHANCEMENT, "Off");
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | @Nullable
|
---|
| 117 | public String getColourModeDescription()
|
---|
| 118 | {
|
---|
| 119 | return getIndexedDescription(TAG_COLOUR_MODE, "Off");
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | @Nullable
|
---|
| 123 | public String getCcdIsoSensitivityDescription()
|
---|
| 124 | {
|
---|
| 125 | return getIndexedDescription(TAG_CCD_ISO_SENSITIVITY, "Off", "On");
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | @Nullable
|
---|
| 129 | public String getTimeZoneDescription()
|
---|
| 130 | {
|
---|
| 131 | return _directory.getString(TAG_TIME_ZONE);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | @Nullable
|
---|
| 135 | public String getFocusMode2Description()
|
---|
| 136 | {
|
---|
| 137 | Integer value = _directory.getInteger(TAG_FOCUS_MODE_2);
|
---|
| 138 | if (value == null)
|
---|
| 139 | return null;
|
---|
| 140 | switch (value) {
|
---|
| 141 | case 1: return "Fixation";
|
---|
| 142 | case 6: return "Multi-Area Focus";
|
---|
| 143 | default:
|
---|
| 144 | return "Unknown (" + value + ")";
|
---|
| 145 | }
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | @Nullable
|
---|
| 149 | public String getQualityDescription()
|
---|
| 150 | {
|
---|
| 151 | return getIndexedDescription(TAG_QUALITY, 3, "Fine");
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | @Nullable
|
---|
| 155 | public String getSelfTimerDescription()
|
---|
| 156 | {
|
---|
| 157 | return getIndexedDescription(TAG_SELF_TIMER, 1, "Off");
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | @Nullable
|
---|
| 161 | public String getRecordModeDescription()
|
---|
| 162 | {
|
---|
| 163 | return getIndexedDescription(TAG_RECORD_MODE, 2, "Normal");
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | @Nullable
|
---|
| 167 | public String getFlashDistanceDescription()
|
---|
| 168 | {
|
---|
| 169 | return getIndexedDescription(TAG_FLASH_DISTANCE, "Off");
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | @Nullable
|
---|
| 173 | public String getObjectDistanceDescription()
|
---|
| 174 | {
|
---|
| 175 | Integer value = _directory.getInteger(TAG_OBJECT_DISTANCE);
|
---|
| 176 | if (value == null)
|
---|
| 177 | return null;
|
---|
| 178 | return Integer.toString(value) + " mm";
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | @Nullable
|
---|
| 182 | public String getWhiteBalance2Description()
|
---|
| 183 | {
|
---|
| 184 | Integer value = _directory.getInteger(TAG_WHITE_BALANCE_2);
|
---|
| 185 | if (value == null)
|
---|
| 186 | return null;
|
---|
| 187 | switch (value) {
|
---|
| 188 | case 0: return "Manual";
|
---|
| 189 | case 1: return "Auto"; // unsure about this
|
---|
| 190 | case 4: return "Flash"; // unsure about this
|
---|
| 191 | case 12: return "Flash";
|
---|
| 192 | default:
|
---|
| 193 | return "Unknown (" + value + ")";
|
---|
| 194 | }
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | @Nullable
|
---|
| 198 | public String getWhiteBalanceBiasDescription()
|
---|
| 199 | {
|
---|
| 200 | return _directory.getString(TAG_WHITE_BALANCE_BIAS);
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 | @Nullable
|
---|
| 204 | public String getCasioPreviewThumbnailDescription()
|
---|
| 205 | {
|
---|
| 206 | final byte[] bytes = _directory.getByteArray(TAG_PREVIEW_THUMBNAIL);
|
---|
| 207 | if (bytes == null)
|
---|
| 208 | return null;
|
---|
| 209 | return "<" + bytes.length + " bytes of image data>";
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | @Nullable
|
---|
| 213 | public String getSharpnessDescription()
|
---|
| 214 | {
|
---|
| 215 | return getIndexedDescription(TAG_SHARPNESS, "-1", "Normal", "+1");
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | @Nullable
|
---|
| 219 | public String getContrastDescription()
|
---|
| 220 | {
|
---|
| 221 | return getIndexedDescription(TAG_CONTRAST, "-1", "Normal", "+1");
|
---|
| 222 | }
|
---|
| 223 |
|
---|
| 224 | @Nullable
|
---|
| 225 | public String getSaturationDescription()
|
---|
| 226 | {
|
---|
| 227 | return getIndexedDescription(TAG_SATURATION, "-1", "Normal", "+1");
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | @Nullable
|
---|
| 231 | public String getFocalLengthDescription()
|
---|
| 232 | {
|
---|
| 233 | Double value = _directory.getDoubleObject(TAG_FOCAL_LENGTH);
|
---|
[10862] | 234 | return value == null ? null : getFocalLengthDescription(value / 10d);
|
---|
[8132] | 235 | }
|
---|
| 236 |
|
---|
| 237 | @Nullable
|
---|
| 238 | public String getWhiteBalance1Description()
|
---|
| 239 | {
|
---|
| 240 | return getIndexedDescription(
|
---|
| 241 | TAG_WHITE_BALANCE_1,
|
---|
| 242 | "Auto",
|
---|
| 243 | "Daylight",
|
---|
| 244 | "Shade",
|
---|
| 245 | "Tungsten",
|
---|
| 246 | "Florescent",
|
---|
| 247 | "Manual"
|
---|
| 248 | );
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | @Nullable
|
---|
| 252 | public String getIsoSensitivityDescription()
|
---|
| 253 | {
|
---|
| 254 | Integer value = _directory.getInteger(TAG_ISO_SENSITIVITY);
|
---|
| 255 | if (value == null)
|
---|
| 256 | return null;
|
---|
| 257 | switch (value) {
|
---|
| 258 | case 3: return "50";
|
---|
| 259 | case 4: return "64";
|
---|
| 260 | case 6: return "100";
|
---|
| 261 | case 9: return "200";
|
---|
| 262 | default:
|
---|
| 263 | return "Unknown (" + value + ")";
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | @Nullable
|
---|
| 268 | public String getFocusMode1Description()
|
---|
| 269 | {
|
---|
| 270 | return getIndexedDescription(TAG_FOCUS_MODE_1, "Normal", "Macro");
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | @Nullable
|
---|
| 274 | public String getImageSizeDescription()
|
---|
| 275 | {
|
---|
| 276 | Integer value = _directory.getInteger(TAG_IMAGE_SIZE);
|
---|
| 277 | if (value == null)
|
---|
| 278 | return null;
|
---|
| 279 | switch (value) {
|
---|
| 280 | case 0: return "640 x 480 pixels";
|
---|
| 281 | case 4: return "1600 x 1200 pixels";
|
---|
| 282 | case 5: return "2048 x 1536 pixels";
|
---|
| 283 | case 20: return "2288 x 1712 pixels";
|
---|
| 284 | case 21: return "2592 x 1944 pixels";
|
---|
| 285 | case 22: return "2304 x 1728 pixels";
|
---|
| 286 | case 36: return "3008 x 2008 pixels";
|
---|
| 287 | default: return "Unknown (" + value + ")";
|
---|
| 288 | }
|
---|
| 289 | }
|
---|
| 290 |
|
---|
| 291 | @Nullable
|
---|
| 292 | public String getQualityModeDescription()
|
---|
| 293 | {
|
---|
| 294 | return getIndexedDescription(TAG_QUALITY_MODE, 1, "Fine", "Super Fine");
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | @Nullable
|
---|
| 298 | public String getThumbnailOffsetDescription()
|
---|
| 299 | {
|
---|
| 300 | return _directory.getString(TAG_THUMBNAIL_OFFSET);
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | @Nullable
|
---|
| 304 | public String getThumbnailSizeDescription()
|
---|
| 305 | {
|
---|
| 306 | Integer value = _directory.getInteger(TAG_THUMBNAIL_SIZE);
|
---|
| 307 | if (value == null)
|
---|
| 308 | return null;
|
---|
| 309 | return Integer.toString(value) + " bytes";
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | @Nullable
|
---|
| 313 | public String getThumbnailDimensionsDescription()
|
---|
| 314 | {
|
---|
| 315 | int[] dimensions = _directory.getIntArray(TAG_THUMBNAIL_DIMENSIONS);
|
---|
| 316 | if (dimensions == null || dimensions.length != 2)
|
---|
| 317 | return _directory.getString(TAG_THUMBNAIL_DIMENSIONS);
|
---|
| 318 | return dimensions[0] + " x " + dimensions[1] + " pixels";
|
---|
| 319 | }
|
---|
| 320 | }
|
---|