[4231] | 1 | /*
|
---|
| 2 | * This is public domain software - that is, you can do whatever you want
|
---|
| 3 | * with it, and include it software that is licensed under the GNU or the
|
---|
| 4 | * BSD license, or whatever other licence you choose, including proprietary
|
---|
| 5 | * closed source licenses. I do ask that you leave this header in tact.
|
---|
| 6 | *
|
---|
| 7 | * If you make modifications to this code that you think would benefit the
|
---|
| 8 | * wider community, please send me a copy and I'll post it on my site.
|
---|
| 9 | *
|
---|
| 10 | * If you make use of this code, I'd appreciate hearing about it.
|
---|
| 11 | * drew@drewnoakes.com
|
---|
| 12 | * Latest version of this software kept at
|
---|
| 13 | * http://drewnoakes.com/
|
---|
| 14 | */
|
---|
| 15 | package com.drew.metadata.exif;
|
---|
| 16 |
|
---|
| 17 | import com.drew.metadata.Directory;
|
---|
| 18 | import com.drew.metadata.MetadataException;
|
---|
| 19 | import com.drew.metadata.TagDescriptor;
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
| 22 | * Provides human-readable string versions of the tags stored in PentaxMakernoteDirectory.
|
---|
| 23 | *
|
---|
| 24 | * Some information about this makernote taken from here:
|
---|
| 25 | * http://www.ozhiker.com/electronics/pjmt/jpeg_info/pentax_mn.html
|
---|
| 26 | */
|
---|
| 27 | public class PentaxMakernoteDescriptor extends TagDescriptor
|
---|
| 28 | {
|
---|
| 29 | public PentaxMakernoteDescriptor(Directory directory)
|
---|
| 30 | {
|
---|
| 31 | super(directory);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public String getDescription(int tagType) throws MetadataException
|
---|
| 35 | {
|
---|
| 36 | switch (tagType)
|
---|
| 37 | {
|
---|
| 38 | case PentaxMakernoteDirectory.TAG_PENTAX_CAPTURE_MODE:
|
---|
| 39 | return getCaptureModeDescription();
|
---|
| 40 | case PentaxMakernoteDirectory.TAG_PENTAX_QUALITY_LEVEL:
|
---|
| 41 | return getQualityLevelDescription();
|
---|
| 42 | case PentaxMakernoteDirectory.TAG_PENTAX_FOCUS_MODE:
|
---|
| 43 | return getFocusModeDescription();
|
---|
| 44 | case PentaxMakernoteDirectory.TAG_PENTAX_FLASH_MODE:
|
---|
| 45 | return getFlashModeDescription();
|
---|
| 46 | case PentaxMakernoteDirectory.TAG_PENTAX_WHITE_BALANCE:
|
---|
| 47 | return getWhiteBalanceDescription();
|
---|
| 48 | case PentaxMakernoteDirectory.TAG_PENTAX_DIGITAL_ZOOM:
|
---|
| 49 | return getDigitalZoomDescription();
|
---|
| 50 | case PentaxMakernoteDirectory.TAG_PENTAX_SHARPNESS:
|
---|
| 51 | return getSharpnessDescription();
|
---|
| 52 | case PentaxMakernoteDirectory.TAG_PENTAX_CONTRAST:
|
---|
| 53 | return getContrastDescription();
|
---|
| 54 | case PentaxMakernoteDirectory.TAG_PENTAX_SATURATION:
|
---|
| 55 | return getSaturationDescription();
|
---|
| 56 | case PentaxMakernoteDirectory.TAG_PENTAX_ISO_SPEED:
|
---|
| 57 | return getIsoSpeedDescription();
|
---|
| 58 | case PentaxMakernoteDirectory.TAG_PENTAX_COLOUR:
|
---|
| 59 | return getColourDescription();
|
---|
| 60 | default:
|
---|
| 61 | return _directory.getString(tagType);
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | public String getColourDescription() throws MetadataException
|
---|
| 66 | {
|
---|
| 67 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_COLOUR)) return null;
|
---|
| 68 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_COLOUR);
|
---|
| 69 | switch (value)
|
---|
| 70 | {
|
---|
| 71 | case 1: return "Normal";
|
---|
| 72 | case 2: return "Black & White";
|
---|
| 73 | case 3: return "Sepia";
|
---|
| 74 | default: return "Unknown (" + value + ")";
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | public String getIsoSpeedDescription() throws MetadataException
|
---|
| 79 | {
|
---|
| 80 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_ISO_SPEED)) return null;
|
---|
| 81 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_ISO_SPEED);
|
---|
| 82 | switch (value)
|
---|
| 83 | {
|
---|
| 84 | // TODO there must be other values which aren't catered for here
|
---|
| 85 | case 10: return "ISO 100";
|
---|
| 86 | case 16: return "ISO 200";
|
---|
| 87 | case 100: return "ISO 100";
|
---|
| 88 | case 200: return "ISO 200";
|
---|
| 89 | default: return "Unknown (" + value + ")";
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | public String getSaturationDescription() throws MetadataException
|
---|
| 94 | {
|
---|
| 95 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_SATURATION)) return null;
|
---|
| 96 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_SATURATION);
|
---|
| 97 | switch (value)
|
---|
| 98 | {
|
---|
| 99 | case 0: return "Normal";
|
---|
| 100 | case 1: return "Low";
|
---|
| 101 | case 2: return "High";
|
---|
| 102 | default: return "Unknown (" + value + ")";
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | public String getContrastDescription() throws MetadataException
|
---|
| 107 | {
|
---|
| 108 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_CONTRAST)) return null;
|
---|
| 109 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_CONTRAST);
|
---|
| 110 | switch (value)
|
---|
| 111 | {
|
---|
| 112 | case 0: return "Normal";
|
---|
| 113 | case 1: return "Low";
|
---|
| 114 | case 2: return "High";
|
---|
| 115 | default: return "Unknown (" + value + ")";
|
---|
| 116 | }
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | public String getSharpnessDescription() throws MetadataException
|
---|
| 120 | {
|
---|
| 121 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_SHARPNESS)) return null;
|
---|
| 122 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_SHARPNESS);
|
---|
| 123 | switch (value)
|
---|
| 124 | {
|
---|
| 125 | case 0: return "Normal";
|
---|
| 126 | case 1: return "Soft";
|
---|
| 127 | case 2: return "Hard";
|
---|
| 128 | default: return "Unknown (" + value + ")";
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | public String getDigitalZoomDescription() throws MetadataException
|
---|
| 133 | {
|
---|
| 134 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_DIGITAL_ZOOM)) return null;
|
---|
| 135 | float value = _directory.getFloat(PentaxMakernoteDirectory.TAG_PENTAX_DIGITAL_ZOOM);
|
---|
| 136 | if (value==0)
|
---|
| 137 | return "Off";
|
---|
| 138 | return Float.toString(value);
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | public String getWhiteBalanceDescription() throws MetadataException
|
---|
| 142 | {
|
---|
| 143 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_WHITE_BALANCE)) return null;
|
---|
| 144 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_WHITE_BALANCE);
|
---|
| 145 | switch (value)
|
---|
| 146 | {
|
---|
| 147 | case 0: return "Auto";
|
---|
| 148 | case 1: return "Daylight";
|
---|
| 149 | case 2: return "Shade";
|
---|
| 150 | case 3: return "Tungsten";
|
---|
| 151 | case 4: return "Fluorescent";
|
---|
| 152 | case 5: return "Manual";
|
---|
| 153 | default: return "Unknown (" + value + ")";
|
---|
| 154 | }
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | public String getFlashModeDescription() throws MetadataException
|
---|
| 158 | {
|
---|
| 159 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_FLASH_MODE)) return null;
|
---|
| 160 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_FLASH_MODE);
|
---|
| 161 | switch (value)
|
---|
| 162 | {
|
---|
| 163 | case 1: return "Auto";
|
---|
| 164 | case 2: return "Flash On";
|
---|
| 165 | case 4: return "Flash Off";
|
---|
| 166 | case 6: return "Red-eye Reduction";
|
---|
| 167 | default: return "Unknown (" + value + ")";
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | public String getFocusModeDescription() throws MetadataException
|
---|
| 172 | {
|
---|
| 173 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_FOCUS_MODE)) return null;
|
---|
| 174 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_FOCUS_MODE);
|
---|
| 175 | switch (value)
|
---|
| 176 | {
|
---|
| 177 | case 2: return "Custom";
|
---|
| 178 | case 3: return "Auto";
|
---|
| 179 | default: return "Unknown (" + value + ")";
|
---|
| 180 | }
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | public String getQualityLevelDescription() throws MetadataException
|
---|
| 184 | {
|
---|
| 185 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_QUALITY_LEVEL)) return null;
|
---|
| 186 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_QUALITY_LEVEL);
|
---|
| 187 | switch (value)
|
---|
| 188 | {
|
---|
| 189 | case 0: return "Good";
|
---|
| 190 | case 1: return "Better";
|
---|
| 191 | case 2: return "Best";
|
---|
| 192 | default: return "Unknown (" + value + ")";
|
---|
| 193 | }
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | public String getCaptureModeDescription() throws MetadataException
|
---|
| 197 | {
|
---|
| 198 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PENTAX_CAPTURE_MODE)) return null;
|
---|
| 199 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PENTAX_CAPTURE_MODE);
|
---|
| 200 | switch (value)
|
---|
| 201 | {
|
---|
| 202 | case 1: return "Auto";
|
---|
| 203 | case 2: return "Night-scene";
|
---|
| 204 | case 3: return "Manual";
|
---|
| 205 | case 4: return "Multiple";
|
---|
| 206 | default: return "Unknown (" + value + ")";
|
---|
| 207 | }
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | /*
|
---|
| 211 | public String getPrintImageMatchingInfoDescription() throws MetadataException
|
---|
| 212 | {
|
---|
| 213 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PANASONIC_PRINT_IMAGE_MATCHING_INFO)) return null;
|
---|
| 214 | byte[] bytes = _directory.getByteArray(PentaxMakernoteDirectory.TAG_PANASONIC_PRINT_IMAGE_MATCHING_INFO);
|
---|
| 215 | return "(" + bytes.length + " bytes)";
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | public String getMacroModeDescription() throws MetadataException
|
---|
| 219 | {
|
---|
| 220 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PANASONIC_MACRO_MODE)) return null;
|
---|
| 221 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PANASONIC_MACRO_MODE);
|
---|
| 222 | switch (value) {
|
---|
| 223 | case 1:
|
---|
| 224 | return "On";
|
---|
| 225 | case 2:
|
---|
| 226 | return "Off";
|
---|
| 227 | default:
|
---|
| 228 | return "Unknown (" + value + ")";
|
---|
| 229 | }
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | public String getRecordModeDescription() throws MetadataException
|
---|
| 233 | {
|
---|
| 234 | if (!_directory.containsTag(PentaxMakernoteDirectory.TAG_PANASONIC_RECORD_MODE)) return null;
|
---|
| 235 | int value = _directory.getInt(PentaxMakernoteDirectory.TAG_PANASONIC_RECORD_MODE);
|
---|
| 236 | switch (value) {
|
---|
| 237 | case 1:
|
---|
| 238 | return "Normal";
|
---|
| 239 | case 2:
|
---|
| 240 | return "Portrait";
|
---|
| 241 | case 9:
|
---|
| 242 | return "Macro";
|
---|
| 243 | default:
|
---|
| 244 | return "Unknown (" + value + ")";
|
---|
| 245 | }
|
---|
| 246 | }
|
---|
| 247 | */
|
---|
| 248 | }
|
---|