Changeset 8132 in josm for trunk/src/com/drew/metadata/exif/ExifSubIFDDescriptor.java
- Timestamp:
- 2015-03-10T01:17:39+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/ExifSubIFDDescriptor.java
r6127 r8132 1 1 /* 2 * Copyright 2002-201 2Drew Noakes2 * Copyright 2002-2015 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 16 16 * More information about this project is available at: 17 17 * 18 * http ://drewnoakes.com/code/exif/19 * http ://code.google.com/p/metadata-extractor/18 * https://drewnoakes.com/code/exif/ 19 * https://github.com/drewnoakes/metadata-extractor 20 20 */ 21 21 package com.drew.metadata.exif; … … 32 32 import java.util.Map; 33 33 34 import static com.drew.metadata.exif.ExifSubIFDDirectory.*; 35 34 36 /** 35 * Provides human-readable string representations of tag values stored in a <code>ExifSubIFDDirectory</code>.37 * Provides human-readable string representations of tag values stored in a {@link ExifSubIFDDirectory}. 36 38 * 37 * @author Drew Noakes http ://drewnoakes.com39 * @author Drew Noakes https://drewnoakes.com 38 40 */ 39 41 public class ExifSubIFDDescriptor extends TagDescriptor<ExifSubIFDDirectory> … … 60 62 61 63 /** 62 * Returns a descriptive value of the thespecified tag for this image.64 * Returns a descriptive value of the specified tag for this image. 63 65 * Where possible, known values will be substituted here in place of the raw 64 66 * tokens actually kept in the Exif segment. If no substitution is 65 67 * available, the value provided by getString(int) will be returned. 68 * 66 69 * @param tagType the tag to find a description for 67 70 * @return a description of the image's value for the specified tag, or 68 71 * <code>null</code> if the tag hasn't been defined. 69 72 */ 73 @Override 70 74 @Nullable 71 75 public String getDescription(int tagType) 72 76 { 73 77 switch (tagType) { 74 case ExifSubIFDDirectory.TAG_NEW_SUBFILE_TYPE:78 case TAG_NEW_SUBFILE_TYPE: 75 79 return getNewSubfileTypeDescription(); 76 case ExifSubIFDDirectory.TAG_SUBFILE_TYPE:80 case TAG_SUBFILE_TYPE: 77 81 return getSubfileTypeDescription(); 78 case ExifSubIFDDirectory.TAG_THRESHOLDING:82 case TAG_THRESHOLDING: 79 83 return getThresholdingDescription(); 80 case ExifSubIFDDirectory.TAG_FILL_ORDER:84 case TAG_FILL_ORDER: 81 85 return getFillOrderDescription(); 82 case ExifSubIFDDirectory.TAG_EXPOSURE_TIME:86 case TAG_EXPOSURE_TIME: 83 87 return getExposureTimeDescription(); 84 case ExifSubIFDDirectory.TAG_SHUTTER_SPEED:88 case TAG_SHUTTER_SPEED: 85 89 return getShutterSpeedDescription(); 86 case ExifSubIFDDirectory.TAG_FNUMBER:90 case TAG_FNUMBER: 87 91 return getFNumberDescription(); 88 case ExifSubIFDDirectory.TAG_COMPRESSED_AVERAGE_BITS_PER_PIXEL:92 case TAG_COMPRESSED_AVERAGE_BITS_PER_PIXEL: 89 93 return getCompressedAverageBitsPerPixelDescription(); 90 case ExifSubIFDDirectory.TAG_SUBJECT_DISTANCE:94 case TAG_SUBJECT_DISTANCE: 91 95 return getSubjectDistanceDescription(); 92 case ExifSubIFDDirectory.TAG_METERING_MODE:96 case TAG_METERING_MODE: 93 97 return getMeteringModeDescription(); 94 case ExifSubIFDDirectory.TAG_WHITE_BALANCE:98 case TAG_WHITE_BALANCE: 95 99 return getWhiteBalanceDescription(); 96 case ExifSubIFDDirectory.TAG_FLASH:100 case TAG_FLASH: 97 101 return getFlashDescription(); 98 case ExifSubIFDDirectory.TAG_FOCAL_LENGTH:102 case TAG_FOCAL_LENGTH: 99 103 return getFocalLengthDescription(); 100 case ExifSubIFDDirectory.TAG_COLOR_SPACE:104 case TAG_COLOR_SPACE: 101 105 return getColorSpaceDescription(); 102 case ExifSubIFDDirectory.TAG_EXIF_IMAGE_WIDTH:106 case TAG_EXIF_IMAGE_WIDTH: 103 107 return getExifImageWidthDescription(); 104 case ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT:108 case TAG_EXIF_IMAGE_HEIGHT: 105 109 return getExifImageHeightDescription(); 106 case ExifSubIFDDirectory.TAG_FOCAL_PLANE_UNIT:110 case TAG_FOCAL_PLANE_RESOLUTION_UNIT: 107 111 return getFocalPlaneResolutionUnitDescription(); 108 case ExifSubIFDDirectory.TAG_FOCAL_PLANE_X_RES:112 case TAG_FOCAL_PLANE_X_RESOLUTION: 109 113 return getFocalPlaneXResolutionDescription(); 110 case ExifSubIFDDirectory.TAG_FOCAL_PLANE_Y_RES:114 case TAG_FOCAL_PLANE_Y_RESOLUTION: 111 115 return getFocalPlaneYResolutionDescription(); 112 case ExifSubIFDDirectory.TAG_BITS_PER_SAMPLE:116 case TAG_BITS_PER_SAMPLE: 113 117 return getBitsPerSampleDescription(); 114 case ExifSubIFDDirectory.TAG_PHOTOMETRIC_INTERPRETATION:118 case TAG_PHOTOMETRIC_INTERPRETATION: 115 119 return getPhotometricInterpretationDescription(); 116 case ExifSubIFDDirectory.TAG_ROWS_PER_STRIP:120 case TAG_ROWS_PER_STRIP: 117 121 return getRowsPerStripDescription(); 118 case ExifSubIFDDirectory.TAG_STRIP_BYTE_COUNTS:122 case TAG_STRIP_BYTE_COUNTS: 119 123 return getStripByteCountsDescription(); 120 case ExifSubIFDDirectory.TAG_SAMPLES_PER_PIXEL:124 case TAG_SAMPLES_PER_PIXEL: 121 125 return getSamplesPerPixelDescription(); 122 case ExifSubIFDDirectory.TAG_PLANAR_CONFIGURATION:126 case TAG_PLANAR_CONFIGURATION: 123 127 return getPlanarConfigurationDescription(); 124 case ExifSubIFDDirectory.TAG_YCBCR_SUBSAMPLING:128 case TAG_YCBCR_SUBSAMPLING: 125 129 return getYCbCrSubsamplingDescription(); 126 case ExifSubIFDDirectory.TAG_EXPOSURE_PROGRAM:130 case TAG_EXPOSURE_PROGRAM: 127 131 return getExposureProgramDescription(); 128 case ExifSubIFDDirectory.TAG_APERTURE:132 case TAG_APERTURE: 129 133 return getApertureValueDescription(); 130 case ExifSubIFDDirectory.TAG_MAX_APERTURE:134 case TAG_MAX_APERTURE: 131 135 return getMaxApertureValueDescription(); 132 case ExifSubIFDDirectory.TAG_SENSING_METHOD:136 case TAG_SENSING_METHOD: 133 137 return getSensingMethodDescription(); 134 case ExifSubIFDDirectory.TAG_EXPOSURE_BIAS:138 case TAG_EXPOSURE_BIAS: 135 139 return getExposureBiasDescription(); 136 case ExifSubIFDDirectory.TAG_FILE_SOURCE:140 case TAG_FILE_SOURCE: 137 141 return getFileSourceDescription(); 138 case ExifSubIFDDirectory.TAG_SCENE_TYPE:142 case TAG_SCENE_TYPE: 139 143 return getSceneTypeDescription(); 140 case ExifSubIFDDirectory.TAG_COMPONENTS_CONFIGURATION:144 case TAG_COMPONENTS_CONFIGURATION: 141 145 return getComponentConfigurationDescription(); 142 case ExifSubIFDDirectory.TAG_EXIF_VERSION:146 case TAG_EXIF_VERSION: 143 147 return getExifVersionDescription(); 144 case ExifSubIFDDirectory.TAG_FLASHPIX_VERSION:148 case TAG_FLASHPIX_VERSION: 145 149 return getFlashPixVersionDescription(); 146 case ExifSubIFDDirectory.TAG_ISO_EQUIVALENT:150 case TAG_ISO_EQUIVALENT: 147 151 return getIsoEquivalentDescription(); 148 case ExifSubIFDDirectory.TAG_USER_COMMENT:152 case TAG_USER_COMMENT: 149 153 return getUserCommentDescription(); 150 case ExifSubIFDDirectory.TAG_CUSTOM_RENDERED:154 case TAG_CUSTOM_RENDERED: 151 155 return getCustomRenderedDescription(); 152 case ExifSubIFDDirectory.TAG_EXPOSURE_MODE:156 case TAG_EXPOSURE_MODE: 153 157 return getExposureModeDescription(); 154 case ExifSubIFDDirectory.TAG_WHITE_BALANCE_MODE:158 case TAG_WHITE_BALANCE_MODE: 155 159 return getWhiteBalanceModeDescription(); 156 case ExifSubIFDDirectory.TAG_DIGITAL_ZOOM_RATIO:160 case TAG_DIGITAL_ZOOM_RATIO: 157 161 return getDigitalZoomRatioDescription(); 158 case ExifSubIFDDirectory.TAG_35MM_FILM_EQUIV_FOCAL_LENGTH:162 case TAG_35MM_FILM_EQUIV_FOCAL_LENGTH: 159 163 return get35mmFilmEquivFocalLengthDescription(); 160 case ExifSubIFDDirectory.TAG_SCENE_CAPTURE_TYPE:164 case TAG_SCENE_CAPTURE_TYPE: 161 165 return getSceneCaptureTypeDescription(); 162 case ExifSubIFDDirectory.TAG_GAIN_CONTROL:166 case TAG_GAIN_CONTROL: 163 167 return getGainControlDescription(); 164 case ExifSubIFDDirectory.TAG_CONTRAST:168 case TAG_CONTRAST: 165 169 return getContrastDescription(); 166 case ExifSubIFDDirectory.TAG_SATURATION:170 case TAG_SATURATION: 167 171 return getSaturationDescription(); 168 case ExifSubIFDDirectory.TAG_SHARPNESS:172 case TAG_SHARPNESS: 169 173 return getSharpnessDescription(); 170 case ExifSubIFDDirectory.TAG_SUBJECT_DISTANCE_RANGE:174 case TAG_SUBJECT_DISTANCE_RANGE: 171 175 return getSubjectDistanceRangeDescription(); 172 176 default: … … 178 182 public String getNewSubfileTypeDescription() 179 183 { 180 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_NEW_SUBFILE_TYPE); 181 if (value==null) 182 return null; 183 switch (value) { 184 case 1: return "Full-resolution image"; 185 case 2: return "Reduced-resolution image"; 186 case 3: return "Single page of multi-page reduced-resolution image"; 187 case 4: return "Transparency mask"; 188 case 5: return "Transparency mask of reduced-resolution image"; 189 case 6: return "Transparency mask of multi-page image"; 190 case 7: return "Transparency mask of reduced-resolution multi-page image"; 191 default: 192 return "Unknown (" + value + ")"; 193 } 184 return getIndexedDescription(TAG_NEW_SUBFILE_TYPE, 1, 185 "Full-resolution image", 186 "Reduced-resolution image", 187 "Single page of multi-page reduced-resolution image", 188 "Transparency mask", 189 "Transparency mask of reduced-resolution image", 190 "Transparency mask of multi-page image", 191 "Transparency mask of reduced-resolution multi-page image" 192 ); 194 193 } 195 194 … … 197 196 public String getSubfileTypeDescription() 198 197 { 199 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_SUBFILE_TYPE); 200 if (value==null) 201 return null; 202 switch (value) { 203 case 1: return "Full-resolution image"; 204 case 2: return "Reduced-resolution image"; 205 case 3: return "Single page of multi-page image"; 206 default: 207 return "Unknown (" + value + ")"; 208 } 198 return getIndexedDescription(TAG_SUBFILE_TYPE, 1, 199 "Full-resolution image", 200 "Reduced-resolution image", 201 "Single page of multi-page image" 202 ); 209 203 } 210 204 … … 212 206 public String getThresholdingDescription() 213 207 { 214 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_THRESHOLDING); 215 if (value==null) 216 return null; 217 switch (value) { 218 case 1: return "No dithering or halftoning"; 219 case 2: return "Ordered dither or halftone"; 220 case 3: return "Randomized dither"; 221 default: 222 return "Unknown (" + value + ")"; 223 } 208 return getIndexedDescription(TAG_THRESHOLDING, 1, 209 "No dithering or halftoning", 210 "Ordered dither or halftone", 211 "Randomized dither" 212 ); 224 213 } 225 214 … … 227 216 public String getFillOrderDescription() 228 217 { 229 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_FILL_ORDER); 230 if (value==null) 231 return null; 232 switch (value) { 233 case 1: return "Normal"; 234 case 2: return "Reversed"; 235 default: 236 return "Unknown (" + value + ")"; 237 } 218 return getIndexedDescription(TAG_FILL_ORDER, 1, 219 "Normal", 220 "Reversed" 221 ); 238 222 } 239 223 … … 241 225 public String getSubjectDistanceRangeDescription() 242 226 { 243 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_SUBJECT_DISTANCE_RANGE); 244 if (value==null) 245 return null; 246 switch (value) { 247 case 0: return "Unknown"; 248 case 1: return "Macro"; 249 case 2: return "Close view"; 250 case 3: return "Distant view"; 251 default: 252 return "Unknown (" + value + ")"; 253 } 227 return getIndexedDescription(TAG_SUBJECT_DISTANCE_RANGE, 228 "Unknown", 229 "Macro", 230 "Close view", 231 "Distant view" 232 ); 254 233 } 255 234 … … 257 236 public String getSharpnessDescription() 258 237 { 259 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_SHARPNESS); 260 if (value==null) 261 return null; 262 switch (value) { 263 case 0: return "None"; 264 case 1: return "Low"; 265 case 2: return "Hard"; 266 default: 267 return "Unknown (" + value + ")"; 268 } 238 return getIndexedDescription(TAG_SHARPNESS, 239 "None", 240 "Low", 241 "Hard" 242 ); 269 243 } 270 244 … … 272 246 public String getSaturationDescription() 273 247 { 274 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_SATURATION); 275 if (value==null) 276 return null; 277 switch (value) { 278 case 0: return "None"; 279 case 1: return "Low saturation"; 280 case 2: return "High saturation"; 281 default: 282 return "Unknown (" + value + ")"; 283 } 248 return getIndexedDescription(TAG_SATURATION, 249 "None", 250 "Low saturation", 251 "High saturation" 252 ); 284 253 } 285 254 … … 287 256 public String getContrastDescription() 288 257 { 289 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_CONTRAST); 290 if (value==null) 291 return null; 292 switch (value) { 293 case 0: return "None"; 294 case 1: return "Soft"; 295 case 2: return "Hard"; 296 default: 297 return "Unknown (" + value + ")"; 298 } 258 return getIndexedDescription(TAG_CONTRAST, 259 "None", 260 "Soft", 261 "Hard" 262 ); 299 263 } 300 264 … … 302 266 public String getGainControlDescription() 303 267 { 304 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_GAIN_CONTROL); 305 if (value==null) 306 return null; 307 switch (value) { 308 case 0: return "None"; 309 case 1: return "Low gain up"; 310 case 2: return "Low gain down"; 311 case 3: return "High gain up"; 312 case 4: return "High gain down"; 313 default: 314 return "Unknown (" + value + ")"; 315 } 268 return getIndexedDescription(TAG_GAIN_CONTROL, 269 "None", 270 "Low gain up", 271 "Low gain down", 272 "High gain up", 273 "High gain down" 274 ); 316 275 } 317 276 … … 319 278 public String getSceneCaptureTypeDescription() 320 279 { 321 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_SCENE_CAPTURE_TYPE); 322 if (value==null) 323 return null; 324 switch (value) { 325 case 0: return "Standard"; 326 case 1: return "Landscape"; 327 case 2: return "Portrait"; 328 case 3: return "Night scene"; 329 default: 330 return "Unknown (" + value + ")"; 331 } 280 return getIndexedDescription(TAG_SCENE_CAPTURE_TYPE, 281 "Standard", 282 "Landscape", 283 "Portrait", 284 "Night scene" 285 ); 332 286 } 333 287 … … 335 289 public String get35mmFilmEquivFocalLengthDescription() 336 290 { 337 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_35MM_FILM_EQUIV_FOCAL_LENGTH); 338 if (value==null) 339 return null; 340 if (value==0) 341 return "Unknown"; 342 else 343 return SimpleDecimalFormatter.format(value) + "mm"; 291 Integer value = _directory.getInteger(TAG_35MM_FILM_EQUIV_FOCAL_LENGTH); 292 return value == null 293 ? null 294 : value == 0 295 ? "Unknown" 296 : SimpleDecimalFormatter.format(value) + "mm"; 344 297 } 345 298 … … 347 300 public String getDigitalZoomRatioDescription() 348 301 { 349 Rational value = _directory.getRational( ExifSubIFDDirectory.TAG_DIGITAL_ZOOM_RATIO);350 if (value==null)351 return null;352 if (value.getNumerator()==0)353 return "Digital zoom not used.";354 returnSimpleDecimalFormatter.format(value.doubleValue());302 Rational value = _directory.getRational(TAG_DIGITAL_ZOOM_RATIO); 303 return value == null 304 ? null 305 : value.getNumerator() == 0 306 ? "Digital zoom not used." 307 : SimpleDecimalFormatter.format(value.doubleValue()); 355 308 } 356 309 … … 358 311 public String getWhiteBalanceModeDescription() 359 312 { 360 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_WHITE_BALANCE_MODE); 361 if (value==null) 362 return null; 363 switch (value) { 364 case 0: return "Auto white balance"; 365 case 1: return "Manual white balance"; 366 default: 367 return "Unknown (" + value + ")"; 368 } 313 return getIndexedDescription(TAG_WHITE_BALANCE_MODE, 314 "Auto white balance", 315 "Manual white balance" 316 ); 369 317 } 370 318 … … 372 320 public String getExposureModeDescription() 373 321 { 374 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_EXPOSURE_MODE); 375 if (value==null) 376 return null; 377 switch (value) { 378 case 0: return "Auto exposure"; 379 case 1: return "Manual exposure"; 380 case 2: return "Auto bracket"; 381 default: 382 return "Unknown (" + value + ")"; 383 } 322 return getIndexedDescription(TAG_EXPOSURE_MODE, 323 "Auto exposure", 324 "Manual exposure", 325 "Auto bracket" 326 ); 384 327 } 385 328 … … 387 330 public String getCustomRenderedDescription() 388 331 { 389 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_CUSTOM_RENDERED); 390 if (value==null) 391 return null; 392 switch (value) { 393 case 0: return "Normal process"; 394 case 1: return "Custom process"; 395 default: 396 return "Unknown (" + value + ")"; 397 } 332 return getIndexedDescription(TAG_CUSTOM_RENDERED, 333 "Normal process", 334 "Custom process" 335 ); 398 336 } 399 337 … … 401 339 public String getUserCommentDescription() 402 340 { 403 byte[] commentBytes = _directory.getByteArray( ExifSubIFDDirectory.TAG_USER_COMMENT);404 if (commentBytes ==null)341 byte[] commentBytes = _directory.getByteArray(TAG_USER_COMMENT); 342 if (commentBytes == null) 405 343 return null; 406 344 if (commentBytes.length == 0) … … 408 346 409 347 final Map<String, String> encodingMap = new HashMap<String, String>(); 410 encodingMap.put("ASCII", 411 encodingMap.put("UNICODE", 412 encodingMap.put("JIS", 348 encodingMap.put("ASCII", System.getProperty("file.encoding")); // Someone suggested "ISO-8859-1". 349 encodingMap.put("UNICODE", "UTF-16LE"); 350 encodingMap.put("JIS", "Shift-JIS"); // We assume this charset for now. Another suggestion is "JIS". 413 351 414 352 try { … … 442 380 { 443 381 // Have seen an exception here from files produced by ACDSEE that stored an int[] here with two values 444 Integer isoEquiv = _directory.getInteger(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT); 445 if (isoEquiv==null) 446 return null; 382 Integer isoEquiv = _directory.getInteger(TAG_ISO_EQUIVALENT); 447 383 // There used to be a check here that multiplied ISO values < 50 by 200. 448 384 // Issue 36 shows a smart-phone image from a Samsung Galaxy S2 with ISO-40. 449 return Integer.toString(isoEquiv); 385 return isoEquiv != null 386 ? Integer.toString(isoEquiv) 387 : null; 450 388 } 451 389 … … 453 391 public String getExifVersionDescription() 454 392 { 455 int[] ints = _directory.getIntArray(ExifSubIFDDirectory.TAG_EXIF_VERSION); 456 if (ints==null) 457 return null; 458 return ExifSubIFDDescriptor.convertBytesToVersionString(ints, 2); 393 return getVersionBytesDescription(TAG_EXIF_VERSION, 2); 459 394 } 460 395 … … 462 397 public String getFlashPixVersionDescription() 463 398 { 464 int[] ints = _directory.getIntArray(ExifSubIFDDirectory.TAG_FLASHPIX_VERSION); 465 if (ints==null) 466 return null; 467 return ExifSubIFDDescriptor.convertBytesToVersionString(ints, 2); 399 return getVersionBytesDescription(TAG_FLASHPIX_VERSION, 2); 468 400 } 469 401 … … 471 403 public String getSceneTypeDescription() 472 404 { 473 Integer sceneType = _directory.getInteger(ExifSubIFDDirectory.TAG_SCENE_TYPE); 474 if (sceneType==null) 475 return null; 476 return sceneType == 1 477 ? "Directly photographed image" 478 : "Unknown (" + sceneType + ")"; 405 return getIndexedDescription(TAG_SCENE_TYPE, 406 1, 407 "Directly photographed image" 408 ); 479 409 } 480 410 … … 482 412 public String getFileSourceDescription() 483 413 { 484 Integer fileSource = _directory.getInteger(ExifSubIFDDirectory.TAG_FILE_SOURCE);485 if (fileSource==null)486 return null;487 return fileSource == 3488 ?"Digital Still Camera (DSC)"489 : "Unknown (" + fileSource + ")";414 return getIndexedDescription(TAG_FILE_SOURCE, 415 1, 416 "Film Scanner", 417 "Reflection Print Scanner", 418 "Digital Still Camera (DSC)" 419 ); 490 420 } 491 421 … … 493 423 public String getExposureBiasDescription() 494 424 { 495 Rational value = _directory.getRational( ExifSubIFDDirectory.TAG_EXPOSURE_BIAS);496 if (value ==null)425 Rational value = _directory.getRational(TAG_EXPOSURE_BIAS); 426 if (value == null) 497 427 return null; 498 428 return value.toSimpleString(true) + " EV"; … … 502 432 public String getMaxApertureValueDescription() 503 433 { 504 Double aperture = _directory.getDoubleObject( ExifSubIFDDirectory.TAG_MAX_APERTURE);505 if (aperture ==null)434 Double aperture = _directory.getDoubleObject(TAG_MAX_APERTURE); 435 if (aperture == null) 506 436 return null; 507 437 double fStop = PhotographicConversions.apertureToFStop(aperture); … … 512 442 public String getApertureValueDescription() 513 443 { 514 Double aperture = _directory.getDoubleObject( ExifSubIFDDirectory.TAG_APERTURE);515 if (aperture ==null)444 Double aperture = _directory.getDoubleObject(TAG_APERTURE); 445 if (aperture == null) 516 446 return null; 517 447 double fStop = PhotographicConversions.apertureToFStop(aperture); … … 522 452 public String getExposureProgramDescription() 523 453 { 524 // '1' means manual control, '2' program normal, '3' aperture priority, 525 // '4' shutter priority, '5' program creative (slow program), 526 // '6' program action(high-speed program), '7' portrait mode, '8' landscape mode. 527 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_EXPOSURE_PROGRAM); 528 if (value==null) 529 return null; 530 switch (value) { 531 case 1: return "Manual control"; 532 case 2: return "Program normal"; 533 case 3: return "Aperture priority"; 534 case 4: return "Shutter priority"; 535 case 5: return "Program creative (slow program)"; 536 case 6: return "Program action (high-speed program)"; 537 case 7: return "Portrait mode"; 538 case 8: return "Landscape mode"; 539 default: 540 return "Unknown program (" + value + ")"; 541 } 454 return getIndexedDescription(TAG_EXPOSURE_PROGRAM, 455 1, 456 "Manual control", 457 "Program normal", 458 "Aperture priority", 459 "Shutter priority", 460 "Program creative (slow program)", 461 "Program action (high-speed program)", 462 "Portrait mode", 463 "Landscape mode" 464 ); 542 465 } 543 466 … … 545 468 public String getYCbCrSubsamplingDescription() 546 469 { 547 int[] positions = _directory.getIntArray( ExifSubIFDDirectory.TAG_YCBCR_SUBSAMPLING);548 if (positions ==null)470 int[] positions = _directory.getIntArray(TAG_YCBCR_SUBSAMPLING); 471 if (positions == null) 549 472 return null; 550 473 if (positions[0] == 2 && positions[1] == 1) { … … 564 487 // pixel. If value is '2', Y/Cb/Cr value is separated and stored to Y plane/Cb plane/Cr 565 488 // plane format. 566 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_PLANAR_CONFIGURATION); 567 if (value==null) 568 return null; 569 switch (value) { 570 case 1: return "Chunky (contiguous for each subsampling pixel)"; 571 case 2: return "Separate (Y-plane/Cb-plane/Cr-plane format)"; 572 default: 573 return "Unknown configuration"; 574 } 489 return getIndexedDescription(TAG_PLANAR_CONFIGURATION, 490 1, 491 "Chunky (contiguous for each subsampling pixel)", 492 "Separate (Y-plane/Cb-plane/Cr-plane format)" 493 ); 575 494 } 576 495 … … 578 497 public String getSamplesPerPixelDescription() 579 498 { 580 String value = _directory.getString( ExifSubIFDDirectory.TAG_SAMPLES_PER_PIXEL);581 return value ==null ? null : value + " samples/pixel";499 String value = _directory.getString(TAG_SAMPLES_PER_PIXEL); 500 return value == null ? null : value + " samples/pixel"; 582 501 } 583 502 … … 585 504 public String getRowsPerStripDescription() 586 505 { 587 final String value = _directory.getString( ExifSubIFDDirectory.TAG_ROWS_PER_STRIP);588 return value ==null ? null : value + " rows/strip";506 final String value = _directory.getString(TAG_ROWS_PER_STRIP); 507 return value == null ? null : value + " rows/strip"; 589 508 } 590 509 … … 592 511 public String getStripByteCountsDescription() 593 512 { 594 final String value = _directory.getString( ExifSubIFDDirectory.TAG_STRIP_BYTE_COUNTS);595 return value ==null ? null : value + " bytes";513 final String value = _directory.getString(TAG_STRIP_BYTE_COUNTS); 514 return value == null ? null : value + " bytes"; 596 515 } 597 516 … … 600 519 { 601 520 // Shows the color space of the image data components 602 Integer value = _directory.getInteger( ExifSubIFDDirectory.TAG_PHOTOMETRIC_INTERPRETATION);603 if (value ==null)521 Integer value = _directory.getInteger(TAG_PHOTOMETRIC_INTERPRETATION); 522 if (value == null) 604 523 return null; 605 524 switch (value) { … … 626 545 public String getBitsPerSampleDescription() 627 546 { 628 String value = _directory.getString( ExifSubIFDDirectory.TAG_BITS_PER_SAMPLE);629 return value ==null ? null : value + " bits/component/pixel";547 String value = _directory.getString(TAG_BITS_PER_SAMPLE); 548 return value == null ? null : value + " bits/component/pixel"; 630 549 } 631 550 … … 633 552 public String getFocalPlaneXResolutionDescription() 634 553 { 635 Rational rational = _directory.getRational( ExifSubIFDDirectory.TAG_FOCAL_PLANE_X_RES);636 if (rational ==null)554 Rational rational = _directory.getRational(TAG_FOCAL_PLANE_X_RESOLUTION); 555 if (rational == null) 637 556 return null; 638 557 final String unit = getFocalPlaneResolutionUnitDescription(); 639 558 return rational.getReciprocal().toSimpleString(_allowDecimalRepresentationOfRationals) 640 + (unit ==null ? "" : " " + unit.toLowerCase());559 + (unit == null ? "" : " " + unit.toLowerCase()); 641 560 } 642 561 … … 644 563 public String getFocalPlaneYResolutionDescription() 645 564 { 646 Rational rational = _directory.getRational( ExifSubIFDDirectory.TAG_FOCAL_PLANE_Y_RES);647 if (rational ==null)565 Rational rational = _directory.getRational(TAG_FOCAL_PLANE_Y_RESOLUTION); 566 if (rational == null) 648 567 return null; 649 568 final String unit = getFocalPlaneResolutionUnitDescription(); 650 569 return rational.getReciprocal().toSimpleString(_allowDecimalRepresentationOfRationals) 651 + (unit ==null ? "" : " " + unit.toLowerCase());570 + (unit == null ? "" : " " + unit.toLowerCase()); 652 571 } 653 572 … … 655 574 public String getFocalPlaneResolutionUnitDescription() 656 575 { 657 // Unit of FocalPlaneXResolution/FocalPlaneYResolution. '1' means no-unit, 658 // '2' inch, '3' centimeter. 659 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_FOCAL_PLANE_UNIT); 660 if (value==null) 661 return null; 662 switch (value) { 663 case 1: return "(No unit)"; 664 case 2: return "Inches"; 665 case 3: return "cm"; 666 default: 667 return ""; 668 } 576 // Unit of FocalPlaneXResolution/FocalPlaneYResolution. 577 // '1' means no-unit, '2' inch, '3' centimeter. 578 return getIndexedDescription(TAG_FOCAL_PLANE_RESOLUTION_UNIT, 579 1, 580 "(No unit)", 581 "Inches", 582 "cm" 583 ); 669 584 } 670 585 … … 672 587 public String getExifImageWidthDescription() 673 588 { 674 final Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_EXIF_IMAGE_WIDTH); 675 if (value==null) 676 return null; 677 return value + " pixels"; 589 final Integer value = _directory.getInteger(TAG_EXIF_IMAGE_WIDTH); 590 return value == null ? null : value + " pixels"; 678 591 } 679 592 … … 681 594 public String getExifImageHeightDescription() 682 595 { 683 final Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT); 684 if (value==null) 685 return null; 686 return value + " pixels"; 596 final Integer value = _directory.getInteger(TAG_EXIF_IMAGE_HEIGHT); 597 return value == null ? null : value + " pixels"; 687 598 } 688 599 … … 690 601 public String getColorSpaceDescription() 691 602 { 692 final Integer value = _directory.getInteger( ExifSubIFDDirectory.TAG_COLOR_SPACE);693 if (value ==null)603 final Integer value = _directory.getInteger(TAG_COLOR_SPACE); 604 if (value == null) 694 605 return null; 695 606 if (value == 1) … … 697 608 if (value == 65535) 698 609 return "Undefined"; 699 return "Unknown ";610 return "Unknown (" + value + ")"; 700 611 } 701 612 … … 703 614 public String getFocalLengthDescription() 704 615 { 705 Rational value = _directory.getRational( ExifSubIFDDirectory.TAG_FOCAL_LENGTH);706 if (value ==null)616 Rational value = _directory.getRational(TAG_FOCAL_LENGTH); 617 if (value == null) 707 618 return null; 708 619 java.text.DecimalFormat formatter = new DecimalFormat("0.0##"); … … 714 625 { 715 626 /* 716 * This is a bit mask.627 * This is a bit mask. 717 628 * 0 = flash fired 718 629 * 1 = return detected … … 724 635 */ 725 636 726 final Integer value = _directory.getInteger( ExifSubIFDDirectory.TAG_FLASH);727 728 if (value ==null)637 final Integer value = _directory.getInteger(TAG_FLASH); 638 639 if (value == null) 729 640 return null; 730 641 731 642 StringBuilder sb = new StringBuilder(); 732 643 733 if ((value & 0x1) !=0)644 if ((value & 0x1) != 0) 734 645 sb.append("Flash fired"); 735 646 else … … 737 648 738 649 // check if we're able to detect a return, before we mention it 739 if ((value & 0x4)!=0) 740 { 741 if ((value & 0x2)!=0) 650 if ((value & 0x4) != 0) { 651 if ((value & 0x2) != 0) 742 652 sb.append(", return detected"); 743 653 else … … 745 655 } 746 656 747 if ((value & 0x10) !=0)657 if ((value & 0x10) != 0) 748 658 sb.append(", auto"); 749 659 750 if ((value & 0x40) !=0)660 if ((value & 0x40) != 0) 751 661 sb.append(", red-eye reduction"); 752 662 … … 760 670 // '17' standard light A, '18' standard light B, '19' standard light C, '20' D55, 761 671 // '21' D65, '22' D75, '255' other. 762 final Integer value = _directory.getInteger( ExifSubIFDDirectory.TAG_WHITE_BALANCE);763 if (value ==null)672 final Integer value = _directory.getInteger(TAG_WHITE_BALANCE); 673 if (value == null) 764 674 return null; 765 675 switch (value) { … … 786 696 // '0' means unknown, '1' average, '2' center weighted average, '3' spot 787 697 // '4' multi-spot, '5' multi-segment, '6' partial, '255' other 788 Integer value = _directory.getInteger( ExifSubIFDDirectory.TAG_METERING_MODE);789 if (value ==null)698 Integer value = _directory.getInteger(TAG_METERING_MODE); 699 if (value == null) 790 700 return null; 791 701 switch (value) { … … 806 716 public String getSubjectDistanceDescription() 807 717 { 808 Rational value = _directory.getRational( ExifSubIFDDirectory.TAG_SUBJECT_DISTANCE);809 if (value ==null)718 Rational value = _directory.getRational(TAG_SUBJECT_DISTANCE); 719 if (value == null) 810 720 return null; 811 721 java.text.DecimalFormat formatter = new DecimalFormat("0.0##"); … … 816 726 public String getCompressedAverageBitsPerPixelDescription() 817 727 { 818 Rational value = _directory.getRational( ExifSubIFDDirectory.TAG_COMPRESSED_AVERAGE_BITS_PER_PIXEL);819 if (value ==null)728 Rational value = _directory.getRational(TAG_COMPRESSED_AVERAGE_BITS_PER_PIXEL); 729 if (value == null) 820 730 return null; 821 731 String ratio = value.toSimpleString(_allowDecimalRepresentationOfRationals); 822 if (value.isInteger() && value.intValue() == 1) { 823 return ratio + " bit/pixel"; 824 } else { 825 return ratio + " bits/pixel"; 826 } 732 return value.isInteger() && value.intValue() == 1 733 ? ratio + " bit/pixel" 734 : ratio + " bits/pixel"; 827 735 } 828 736 … … 830 738 public String getExposureTimeDescription() 831 739 { 832 String value = _directory.getString( ExifSubIFDDirectory.TAG_EXPOSURE_TIME);833 return value ==null ? null : value + " sec";740 String value = _directory.getString(TAG_EXPOSURE_TIME); 741 return value == null ? null : value + " sec"; 834 742 } 835 743 … … 847 755 // description (spotted bug using a Canon EOS 300D) 848 756 // thanks also to Gli Blr for spotting this bug 849 Float apexValue = _directory.getFloatObject( ExifSubIFDDirectory.TAG_SHUTTER_SPEED);850 if (apexValue ==null)851 return null; 852 if (apexValue <=1) {853 float apexPower = (float)(1 /(Math.exp(apexValue*Math.log(2))));757 Float apexValue = _directory.getFloatObject(TAG_SHUTTER_SPEED); 758 if (apexValue == null) 759 return null; 760 if (apexValue <= 1) { 761 float apexPower = (float)(1 / (Math.exp(apexValue * Math.log(2)))); 854 762 long apexPower10 = Math.round((double)apexPower * 10.0); 855 float fApexPower = (float) 763 float fApexPower = (float)apexPower10 / 10.0f; 856 764 return fApexPower + " sec"; 857 765 } else { 858 int apexPower = (int)((Math.exp(apexValue *Math.log(2))));766 int apexPower = (int)((Math.exp(apexValue * Math.log(2)))); 859 767 return "1/" + apexPower + " sec"; 860 768 } … … 879 787 return sb.toString(); 880 788 */ 881 882 789 } 883 790 … … 885 792 public String getFNumberDescription() 886 793 { 887 Rational value = _directory.getRational( ExifSubIFDDirectory.TAG_FNUMBER);888 if (value ==null)794 Rational value = _directory.getRational(TAG_FNUMBER); 795 if (value == null) 889 796 return null; 890 797 return "F" + SimpleDecimalFormatter.format(value.doubleValue()); … … 897 804 // '4' Three-chip color area sensor, '5' Color sequential area sensor 898 805 // '7' Trilinear sensor '8' Color sequential linear sensor, 'Other' reserved 899 Integer value = _directory.getInteger(ExifSubIFDDirectory.TAG_SENSING_METHOD); 900 if (value==null) 901 return null; 902 switch (value) { 903 case 1: return "(Not defined)"; 904 case 2: return "One-chip color area sensor"; 905 case 3: return "Two-chip color area sensor"; 906 case 4: return "Three-chip color area sensor"; 907 case 5: return "Color sequential area sensor"; 908 case 7: return "Trilinear sensor"; 909 case 8: return "Color sequential linear sensor"; 910 default: 911 return ""; 912 } 806 return getIndexedDescription(TAG_SENSING_METHOD, 807 1, 808 "(Not defined)", 809 "One-chip color area sensor", 810 "Two-chip color area sensor", 811 "Three-chip color area sensor", 812 "Color sequential area sensor", 813 null, 814 "Trilinear sensor", 815 "Color sequential linear sensor" 816 ); 913 817 } 914 818 … … 916 820 public String getComponentConfigurationDescription() 917 821 { 918 int[] components = _directory.getIntArray( ExifSubIFDDirectory.TAG_COMPONENTS_CONFIGURATION);919 if (components ==null)822 int[] components = _directory.getIntArray(TAG_COMPONENTS_CONFIGURATION); 823 if (components == null) 920 824 return null; 921 825 String[] componentStrings = {"", "Y", "Cb", "Cr", "R", "G", "B"};
Note:
See TracChangeset
for help on using the changeset viewer.