Changeset 8243 in josm for trunk/src/com/drew/metadata/exif/ExifThumbnailDescriptor.java
- Timestamp:
- 2015-04-21T00:42:50+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/ExifThumbnailDescriptor.java
r8132 r8243 22 22 package com.drew.metadata.exif; 23 23 24 import com.drew.lang.Rational;25 24 import com.drew.lang.annotations.NotNull; 26 25 import com.drew.lang.annotations.Nullable; 27 import com.drew.metadata.TagDescriptor;28 26 29 27 import static com.drew.metadata.exif.ExifThumbnailDirectory.*; … … 34 32 * @author Drew Noakes https://drewnoakes.com 35 33 */ 36 public class ExifThumbnailDescriptor extends TagDescriptor<ExifThumbnailDirectory>34 public class ExifThumbnailDescriptor extends ExifDescriptorBase<ExifThumbnailDirectory> 37 35 { 38 /**39 * Dictates whether rational values will be represented in decimal format in instances40 * where decimal notation is elegant (such as 1/2 -> 0.5, but not 1/3).41 */42 private final boolean _allowDecimalRepresentationOfRationals = true;43 44 36 public ExifThumbnailDescriptor(@NotNull ExifThumbnailDirectory directory) 45 37 { … … 47 39 } 48 40 49 // Note for the potential addition of brightness presentation in eV:50 // Brightness of taken subject. To calculate Exposure(Ev) from BrightnessValue(Bv),51 // you must add SensitivityValue(Sv).52 // Ev=BV+Sv Sv=log2(ISOSpeedRating/3.125)53 // ISO100:Sv=5, ISO200:Sv=6, ISO400:Sv=7, ISO125:Sv=5.32.54 55 /**56 * Returns a descriptive value of the specified tag for this image.57 * Where possible, known values will be substituted here in place of the raw58 * tokens actually kept in the Exif segment. If no substitution is59 * available, the value provided by getString(int) will be returned.60 *61 * @param tagType the tag to find a description for62 * @return a description of the image's value for the specified tag, or63 * <code>null</code> if the tag hasn't been defined.64 */65 41 @Override 66 42 @Nullable … … 68 44 { 69 45 switch (tagType) { 70 case TAG_ORIENTATION:71 return getOrientationDescription();72 case TAG_RESOLUTION_UNIT:73 return getResolutionDescription();74 case TAG_YCBCR_POSITIONING:75 return getYCbCrPositioningDescription();76 case TAG_X_RESOLUTION:77 return getXResolutionDescription();78 case TAG_Y_RESOLUTION:79 return getYResolutionDescription();80 46 case TAG_THUMBNAIL_OFFSET: 81 47 return getThumbnailOffsetDescription(); 82 48 case TAG_THUMBNAIL_LENGTH: 83 49 return getThumbnailLengthDescription(); 84 case TAG_THUMBNAIL_IMAGE_WIDTH:85 return getThumbnailImageWidthDescription();86 case TAG_THUMBNAIL_IMAGE_HEIGHT:87 return getThumbnailImageHeightDescription();88 case TAG_BITS_PER_SAMPLE:89 return getBitsPerSampleDescription();90 50 case TAG_THUMBNAIL_COMPRESSION: 91 51 return getCompressionDescription(); 92 case TAG_PHOTOMETRIC_INTERPRETATION:93 return getPhotometricInterpretationDescription();94 case TAG_ROWS_PER_STRIP:95 return getRowsPerStripDescription();96 case TAG_STRIP_BYTE_COUNTS:97 return getStripByteCountsDescription();98 case TAG_SAMPLES_PER_PIXEL:99 return getSamplesPerPixelDescription();100 case TAG_PLANAR_CONFIGURATION:101 return getPlanarConfigurationDescription();102 case TAG_YCBCR_SUBSAMPLING:103 return getYCbCrSubsamplingDescription();104 case TAG_REFERENCE_BLACK_WHITE:105 return getReferenceBlackWhiteDescription();106 52 default: 107 53 return super.getDescription(tagType); 108 }109 }110 111 @Nullable112 public String getReferenceBlackWhiteDescription()113 {114 int[] ints = _directory.getIntArray(TAG_REFERENCE_BLACK_WHITE);115 if (ints == null || ints.length < 6)116 return null;117 int blackR = ints[0];118 int whiteR = ints[1];119 int blackG = ints[2];120 int whiteG = ints[3];121 int blackB = ints[4];122 int whiteB = ints[5];123 return String.format("[%d,%d,%d] [%d,%d,%d]", blackR, blackG, blackB, whiteR, whiteG, whiteB);124 }125 126 @Nullable127 public String getYCbCrSubsamplingDescription()128 {129 int[] positions = _directory.getIntArray(TAG_YCBCR_SUBSAMPLING);130 if (positions == null || positions.length < 2)131 return null;132 if (positions[0] == 2 && positions[1] == 1) {133 return "YCbCr4:2:2";134 } else if (positions[0] == 2 && positions[1] == 2) {135 return "YCbCr4:2:0";136 } else {137 return "(Unknown)";138 }139 }140 141 @Nullable142 public String getPlanarConfigurationDescription()143 {144 // When image format is no compression YCbCr, this value shows byte aligns of YCbCr145 // data. If value is '1', Y/Cb/Cr value is chunky format, contiguous for each subsampling146 // pixel. If value is '2', Y/Cb/Cr value is separated and stored to Y plane/Cb plane/Cr147 // plane format.148 return getIndexedDescription(TAG_PLANAR_CONFIGURATION,149 1,150 "Chunky (contiguous for each subsampling pixel)",151 "Separate (Y-plane/Cb-plane/Cr-plane format)"152 );153 }154 155 @Nullable156 public String getSamplesPerPixelDescription()157 {158 String value = _directory.getString(TAG_SAMPLES_PER_PIXEL);159 return value == null ? null : value + " samples/pixel";160 }161 162 @Nullable163 public String getRowsPerStripDescription()164 {165 final String value = _directory.getString(TAG_ROWS_PER_STRIP);166 return value == null ? null : value + " rows/strip";167 }168 169 @Nullable170 public String getStripByteCountsDescription()171 {172 final String value = _directory.getString(TAG_STRIP_BYTE_COUNTS);173 return value == null ? null : value + " bytes";174 }175 176 @Nullable177 public String getPhotometricInterpretationDescription()178 {179 // Shows the color space of the image data components180 Integer value = _directory.getInteger(TAG_PHOTOMETRIC_INTERPRETATION);181 if (value == null)182 return null;183 switch (value) {184 case 0: return "WhiteIsZero";185 case 1: return "BlackIsZero";186 case 2: return "RGB";187 case 3: return "RGB Palette";188 case 4: return "Transparency Mask";189 case 5: return "CMYK";190 case 6: return "YCbCr";191 case 8: return "CIELab";192 case 9: return "ICCLab";193 case 10: return "ITULab";194 case 32803: return "Color Filter Array";195 case 32844: return "Pixar LogL";196 case 32845: return "Pixar LogLuv";197 case 32892: return "Linear Raw";198 default:199 return "Unknown colour space";200 54 } 201 55 } … … 241 95 242 96 @Nullable 243 public String getBitsPerSampleDescription()244 {245 String value = _directory.getString(TAG_BITS_PER_SAMPLE);246 return value == null ? null : value + " bits/component/pixel";247 }248 249 @Nullable250 public String getThumbnailImageWidthDescription()251 {252 String value = _directory.getString(TAG_THUMBNAIL_IMAGE_WIDTH);253 return value == null ? null : value + " pixels";254 }255 256 @Nullable257 public String getThumbnailImageHeightDescription()258 {259 String value = _directory.getString(TAG_THUMBNAIL_IMAGE_HEIGHT);260 return value == null ? null : value + " pixels";261 }262 263 @Nullable264 97 public String getThumbnailLengthDescription() 265 98 { … … 274 107 return value == null ? null : value + " bytes"; 275 108 } 276 277 @Nullable278 public String getYResolutionDescription()279 {280 Rational value = _directory.getRational(TAG_Y_RESOLUTION);281 if (value == null)282 return null;283 final String unit = getResolutionDescription();284 return value.toSimpleString(_allowDecimalRepresentationOfRationals) +285 " dots per " +286 (unit == null ? "unit" : unit.toLowerCase());287 }288 289 @Nullable290 public String getXResolutionDescription()291 {292 Rational value = _directory.getRational(TAG_X_RESOLUTION);293 if (value == null)294 return null;295 final String unit = getResolutionDescription();296 return value.toSimpleString(_allowDecimalRepresentationOfRationals) +297 " dots per " +298 (unit == null ? "unit" : unit.toLowerCase());299 }300 301 @Nullable302 public String getYCbCrPositioningDescription()303 {304 return getIndexedDescription(TAG_YCBCR_POSITIONING, 1, "Center of pixel array", "Datum point");305 }306 307 @Nullable308 public String getOrientationDescription()309 {310 return getIndexedDescription(TAG_ORIENTATION, 1,311 "Top, left side (Horizontal / normal)",312 "Top, right side (Mirror horizontal)",313 "Bottom, right side (Rotate 180)",314 "Bottom, left side (Mirror vertical)",315 "Left side, top (Mirror horizontal and rotate 270 CW)",316 "Right side, top (Rotate 90 CW)",317 "Right side, bottom (Mirror horizontal and rotate 90 CW)",318 "Left side, bottom (Rotate 270 CW)");319 }320 321 @Nullable322 public String getResolutionDescription()323 {324 // '1' means no-unit, '2' means inch, '3' means centimeter. Default value is '2'(inch)325 return getIndexedDescription(TAG_RESOLUTION_UNIT, 1, "(No unit)", "Inch", "cm");326 }327 109 }
Note:
See TracChangeset
for help on using the changeset viewer.
