| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
package com.drew.metadata.exif; |
| 23 |
|
| 24 |
import com.drew.imaging.PhotographicConversions; |
| 25 |
import com.drew.lang.Rational; |
| 26 |
import com.drew.lang.annotations.NotNull; |
| 27 |
import com.drew.lang.annotations.Nullable; |
| 28 |
import com.drew.lang.ByteArrayReader; |
| 29 |
import com.drew.metadata.Directory; |
| 30 |
import com.drew.metadata.TagDescriptor; |
| 31 |
|
| 32 |
import java.io.IOException; |
| 33 |
import java.io.UnsupportedEncodingException; |
| 34 |
import java.text.DecimalFormat; |
| 35 |
|
| 36 |
import static com.drew.metadata.exif.ExifDirectoryBase.*; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
@SuppressWarnings("WeakerAccess") |
| 44 |
public abstract class ExifDescriptorBase<T extends Directory> extends TagDescriptor<T> |
| 45 |
{ |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
private final boolean _allowDecimalRepresentationOfRationals = true; |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public ExifDescriptorBase(@NotNull T directory) |
| 59 |
{ |
| 60 |
super(directory); |
| 61 |
} |
| 62 |
|
| 63 |
@Nullable |
| 64 |
@Override |
| 65 |
public String getDescription(int tagType) |
| 66 |
{ |
| 67 |
switch (tagType) { |
| 68 |
case TAG_INTEROP_INDEX: |
| 69 |
return getInteropIndexDescription(); |
| 70 |
case TAG_INTEROP_VERSION: |
| 71 |
return getInteropVersionDescription(); |
| 72 |
case TAG_NEW_SUBFILE_TYPE: |
| 73 |
return getNewSubfileTypeDescription(); |
| 74 |
case TAG_SUBFILE_TYPE: |
| 75 |
return getSubfileTypeDescription(); |
| 76 |
case TAG_IMAGE_WIDTH: |
| 77 |
return getImageWidthDescription(); |
| 78 |
case TAG_IMAGE_HEIGHT: |
| 79 |
return getImageHeightDescription(); |
| 80 |
case TAG_BITS_PER_SAMPLE: |
| 81 |
return getBitsPerSampleDescription(); |
| 82 |
case TAG_COMPRESSION: |
| 83 |
return getCompressionDescription(); |
| 84 |
case TAG_PHOTOMETRIC_INTERPRETATION: |
| 85 |
return getPhotometricInterpretationDescription(); |
| 86 |
case TAG_THRESHOLDING: |
| 87 |
return getThresholdingDescription(); |
| 88 |
case TAG_FILL_ORDER: |
| 89 |
return getFillOrderDescription(); |
| 90 |
case TAG_ORIENTATION: |
| 91 |
return getOrientationDescription(); |
| 92 |
case TAG_SAMPLES_PER_PIXEL: |
| 93 |
return getSamplesPerPixelDescription(); |
| 94 |
case TAG_ROWS_PER_STRIP: |
| 95 |
return getRowsPerStripDescription(); |
| 96 |
case TAG_STRIP_BYTE_COUNTS: |
| 97 |
return getStripByteCountsDescription(); |
| 98 |
case TAG_X_RESOLUTION: |
| 99 |
return getXResolutionDescription(); |
| 100 |
case TAG_Y_RESOLUTION: |
| 101 |
return getYResolutionDescription(); |
| 102 |
case TAG_PLANAR_CONFIGURATION: |
| 103 |
return getPlanarConfigurationDescription(); |
| 104 |
case TAG_RESOLUTION_UNIT: |
| 105 |
return getResolutionDescription(); |
| 106 |
case TAG_JPEG_PROC: |
| 107 |
return getJpegProcDescription(); |
| 108 |
case TAG_YCBCR_SUBSAMPLING: |
| 109 |
return getYCbCrSubsamplingDescription(); |
| 110 |
case TAG_YCBCR_POSITIONING: |
| 111 |
return getYCbCrPositioningDescription(); |
| 112 |
case TAG_REFERENCE_BLACK_WHITE: |
| 113 |
return getReferenceBlackWhiteDescription(); |
| 114 |
case TAG_CFA_PATTERN_2: |
| 115 |
return getCfaPattern2Description(); |
| 116 |
case TAG_EXPOSURE_TIME: |
| 117 |
return getExposureTimeDescription(); |
| 118 |
case TAG_FNUMBER: |
| 119 |
return getFNumberDescription(); |
| 120 |
case TAG_EXPOSURE_PROGRAM: |
| 121 |
return getExposureProgramDescription(); |
| 122 |
case TAG_ISO_EQUIVALENT: |
| 123 |
return getIsoEquivalentDescription(); |
| 124 |
case TAG_SENSITIVITY_TYPE: |
| 125 |
return getSensitivityTypeRangeDescription(); |
| 126 |
case TAG_EXIF_VERSION: |
| 127 |
return getExifVersionDescription(); |
| 128 |
case TAG_COMPONENTS_CONFIGURATION: |
| 129 |
return getComponentConfigurationDescription(); |
| 130 |
case TAG_COMPRESSED_AVERAGE_BITS_PER_PIXEL: |
| 131 |
return getCompressedAverageBitsPerPixelDescription(); |
| 132 |
case TAG_SHUTTER_SPEED: |
| 133 |
return getShutterSpeedDescription(); |
| 134 |
case TAG_APERTURE: |
| 135 |
return getApertureValueDescription(); |
| 136 |
case TAG_BRIGHTNESS_VALUE: |
| 137 |
return getBrightnessValueDescription(); |
| 138 |
case TAG_EXPOSURE_BIAS: |
| 139 |
return getExposureBiasDescription(); |
| 140 |
case TAG_MAX_APERTURE: |
| 141 |
return getMaxApertureValueDescription(); |
| 142 |
case TAG_SUBJECT_DISTANCE: |
| 143 |
return getSubjectDistanceDescription(); |
| 144 |
case TAG_METERING_MODE: |
| 145 |
return getMeteringModeDescription(); |
| 146 |
case TAG_WHITE_BALANCE: |
| 147 |
return getWhiteBalanceDescription(); |
| 148 |
case TAG_FLASH: |
| 149 |
return getFlashDescription(); |
| 150 |
case TAG_FOCAL_LENGTH: |
| 151 |
return getFocalLengthDescription(); |
| 152 |
case TAG_USER_COMMENT: |
| 153 |
return getUserCommentDescription(); |
| 154 |
case TAG_TEMPERATURE: |
| 155 |
return getTemperatureDescription(); |
| 156 |
case TAG_HUMIDITY: |
| 157 |
return getHumidityDescription(); |
| 158 |
case TAG_PRESSURE: |
| 159 |
return getPressureDescription(); |
| 160 |
case TAG_WATER_DEPTH: |
| 161 |
return getWaterDepthDescription(); |
| 162 |
case TAG_ACCELERATION: |
| 163 |
return getAccelerationDescription(); |
| 164 |
case TAG_CAMERA_ELEVATION_ANGLE: |
| 165 |
return getCameraElevationAngleDescription(); |
| 166 |
case TAG_WIN_TITLE: |
| 167 |
return getWindowsTitleDescription(); |
| 168 |
case TAG_WIN_COMMENT: |
| 169 |
return getWindowsCommentDescription(); |
| 170 |
case TAG_WIN_AUTHOR: |
| 171 |
return getWindowsAuthorDescription(); |
| 172 |
case TAG_WIN_KEYWORDS: |
| 173 |
return getWindowsKeywordsDescription(); |
| 174 |
case TAG_WIN_SUBJECT: |
| 175 |
return getWindowsSubjectDescription(); |
| 176 |
case TAG_FLASHPIX_VERSION: |
| 177 |
return getFlashPixVersionDescription(); |
| 178 |
case TAG_COLOR_SPACE: |
| 179 |
return getColorSpaceDescription(); |
| 180 |
case TAG_EXIF_IMAGE_WIDTH: |
| 181 |
return getExifImageWidthDescription(); |
| 182 |
case TAG_EXIF_IMAGE_HEIGHT: |
| 183 |
return getExifImageHeightDescription(); |
| 184 |
case TAG_FOCAL_PLANE_X_RESOLUTION: |
| 185 |
return getFocalPlaneXResolutionDescription(); |
| 186 |
case TAG_FOCAL_PLANE_Y_RESOLUTION: |
| 187 |
return getFocalPlaneYResolutionDescription(); |
| 188 |
case TAG_FOCAL_PLANE_RESOLUTION_UNIT: |
| 189 |
return getFocalPlaneResolutionUnitDescription(); |
| 190 |
case TAG_SENSING_METHOD: |
| 191 |
return getSensingMethodDescription(); |
| 192 |
case TAG_FILE_SOURCE: |
| 193 |
return getFileSourceDescription(); |
| 194 |
case TAG_SCENE_TYPE: |
| 195 |
return getSceneTypeDescription(); |
| 196 |
case TAG_CFA_PATTERN: |
| 197 |
return getCfaPatternDescription(); |
| 198 |
case TAG_CUSTOM_RENDERED: |
| 199 |
return getCustomRenderedDescription(); |
| 200 |
case TAG_EXPOSURE_MODE: |
| 201 |
return getExposureModeDescription(); |
| 202 |
case TAG_WHITE_BALANCE_MODE: |
| 203 |
return getWhiteBalanceModeDescription(); |
| 204 |
case TAG_DIGITAL_ZOOM_RATIO: |
| 205 |
return getDigitalZoomRatioDescription(); |
| 206 |
case TAG_35MM_FILM_EQUIV_FOCAL_LENGTH: |
| 207 |
return get35mmFilmEquivFocalLengthDescription(); |
| 208 |
case TAG_SCENE_CAPTURE_TYPE: |
| 209 |
return getSceneCaptureTypeDescription(); |
| 210 |
case TAG_GAIN_CONTROL: |
| 211 |
return getGainControlDescription(); |
| 212 |
case TAG_CONTRAST: |
| 213 |
return getContrastDescription(); |
| 214 |
case TAG_SATURATION: |
| 215 |
return getSaturationDescription(); |
| 216 |
case TAG_SHARPNESS: |
| 217 |
return getSharpnessDescription(); |
| 218 |
case TAG_SUBJECT_DISTANCE_RANGE: |
| 219 |
return getSubjectDistanceRangeDescription(); |
| 220 |
case TAG_LENS_SPECIFICATION: |
| 221 |
return getLensSpecificationDescription(); |
| 222 |
case TAG_EXTRA_SAMPLES: |
| 223 |
return getExtraSamplesDescription(); |
| 224 |
case TAG_SAMPLE_FORMAT: |
| 225 |
return getSampleFormatDescription(); |
| 226 |
default: |
| 227 |
return super.getDescription(tagType); |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
@Nullable |
| 232 |
public String getInteropIndexDescription() |
| 233 |
{ |
| 234 |
String value = _directory.getString(TAG_INTEROP_INDEX); |
| 235 |
|
| 236 |
if (value == null) |
| 237 |
return null; |
| 238 |
|
| 239 |
return "R98".equalsIgnoreCase(value.trim()) |
| 240 |
? "Recommended Exif Interoperability Rules (ExifR98)" |
| 241 |
: "Unknown (" + value + ")"; |
| 242 |
} |
| 243 |
|
| 244 |
@Nullable |
| 245 |
public String getInteropVersionDescription() |
| 246 |
{ |
| 247 |
return getVersionBytesDescription(TAG_INTEROP_VERSION, 2); |
| 248 |
} |
| 249 |
|
| 250 |
@Nullable |
| 251 |
public String getNewSubfileTypeDescription() |
| 252 |
{ |
| 253 |
return getIndexedDescription(TAG_NEW_SUBFILE_TYPE, 0, |
| 254 |
"Full-resolution image", |
| 255 |
"Reduced-resolution image", |
| 256 |
"Single page of multi-page image", |
| 257 |
"Single page of multi-page reduced-resolution image", |
| 258 |
"Transparency mask", |
| 259 |
"Transparency mask of reduced-resolution image", |
| 260 |
"Transparency mask of multi-page image", |
| 261 |
"Transparency mask of reduced-resolution multi-page image" |
| 262 |
); |
| 263 |
} |
| 264 |
|
| 265 |
@Nullable |
| 266 |
public String getSubfileTypeDescription() |
| 267 |
{ |
| 268 |
return getIndexedDescription(TAG_SUBFILE_TYPE, 1, |
| 269 |
"Full-resolution image", |
| 270 |
"Reduced-resolution image", |
| 271 |
"Single page of multi-page image" |
| 272 |
); |
| 273 |
} |
| 274 |
|
| 275 |
@Nullable |
| 276 |
public String getImageWidthDescription() |
| 277 |
{ |
| 278 |
String value = _directory.getString(TAG_IMAGE_WIDTH); |
| 279 |
return value == null ? null : value + " pixels"; |
| 280 |
} |
| 281 |
|
| 282 |
@Nullable |
| 283 |
public String getImageHeightDescription() |
| 284 |
{ |
| 285 |
String value = _directory.getString(TAG_IMAGE_HEIGHT); |
| 286 |
return value == null ? null : value + " pixels"; |
| 287 |
} |
| 288 |
|
| 289 |
@Nullable |
| 290 |
public String getBitsPerSampleDescription() |
| 291 |
{ |
| 292 |
String value = _directory.getString(TAG_BITS_PER_SAMPLE); |
| 293 |
return value == null ? null : value + " bits/component/pixel"; |
| 294 |
} |
| 295 |
|
| 296 |
@Nullable |
| 297 |
public String getCompressionDescription() |
| 298 |
{ |
| 299 |
Integer value = _directory.getInteger(TAG_COMPRESSION); |
| 300 |
if (value == null) |
| 301 |
return null; |
| 302 |
switch (value) { |
| 303 |
case 1: return "Uncompressed"; |
| 304 |
case 2: return "CCITT 1D"; |
| 305 |
case 3: return "T4/Group 3 Fax"; |
| 306 |
case 4: return "T6/Group 4 Fax"; |
| 307 |
case 5: return "LZW"; |
| 308 |
case 6: return "JPEG (old-style)"; |
| 309 |
case 7: return "JPEG"; |
| 310 |
case 8: return "Adobe Deflate"; |
| 311 |
case 9: return "JBIG B&W"; |
| 312 |
case 10: return "JBIG Color"; |
| 313 |
case 99: return "JPEG"; |
| 314 |
case 262: return "Kodak 262"; |
| 315 |
case 32766: return "Next"; |
| 316 |
case 32767: return "Sony ARW Compressed"; |
| 317 |
case 32769: return "Packed RAW"; |
| 318 |
case 32770: return "Samsung SRW Compressed"; |
| 319 |
case 32771: return "CCIRLEW"; |
| 320 |
case 32772: return "Samsung SRW Compressed 2"; |
| 321 |
case 32773: return "PackBits"; |
| 322 |
case 32809: return "Thunderscan"; |
| 323 |
case 32867: return "Kodak KDC Compressed"; |
| 324 |
case 32895: return "IT8CTPAD"; |
| 325 |
case 32896: return "IT8LW"; |
| 326 |
case 32897: return "IT8MP"; |
| 327 |
case 32898: return "IT8BL"; |
| 328 |
case 32908: return "PixarFilm"; |
| 329 |
case 32909: return "PixarLog"; |
| 330 |
case 32946: return "Deflate"; |
| 331 |
case 32947: return "DCS"; |
| 332 |
case 34661: return "JBIG"; |
| 333 |
case 34676: return "SGILog"; |
| 334 |
case 34677: return "SGILog24"; |
| 335 |
case 34712: return "JPEG 2000"; |
| 336 |
case 34713: return "Nikon NEF Compressed"; |
| 337 |
case 34715: return "JBIG2 TIFF FX"; |
| 338 |
case 34718: return "Microsoft Document Imaging (MDI) Binary Level Codec"; |
| 339 |
case 34719: return "Microsoft Document Imaging (MDI) Progressive Transform Codec"; |
| 340 |
case 34720: return "Microsoft Document Imaging (MDI) Vector"; |
| 341 |
case 34892: return "Lossy JPEG"; |
| 342 |
case 65000: return "Kodak DCR Compressed"; |
| 343 |
case 65535: return "Pentax PEF Compressed"; |
| 344 |
default: |
| 345 |
return "Unknown (" + value + ")"; |
| 346 |
} |
| 347 |
} |
| 348 |
|
| 349 |
@Nullable |
| 350 |
public String getPhotometricInterpretationDescription() |
| 351 |
{ |
| 352 |
|
| 353 |
Integer value = _directory.getInteger(TAG_PHOTOMETRIC_INTERPRETATION); |
| 354 |
if (value == null) |
| 355 |
return null; |
| 356 |
switch (value) { |
| 357 |
case 0: return "WhiteIsZero"; |
| 358 |
case 1: return "BlackIsZero"; |
| 359 |
case 2: return "RGB"; |
| 360 |
case 3: return "RGB Palette"; |
| 361 |
case 4: return "Transparency Mask"; |
| 362 |
case 5: return "CMYK"; |
| 363 |
case 6: return "YCbCr"; |
| 364 |
case 8: return "CIELab"; |
| 365 |
case 9: return "ICCLab"; |
| 366 |
case 10: return "ITULab"; |
| 367 |
case 32803: return "Color Filter Array"; |
| 368 |
case 32844: return "Pixar LogL"; |
| 369 |
case 32845: return "Pixar LogLuv"; |
| 370 |
case 32892: return "Linear Raw"; |
| 371 |
default: |
| 372 |
return "Unknown colour space"; |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
@Nullable |
| 377 |
public String getThresholdingDescription() |
| 378 |
{ |
| 379 |
return getIndexedDescription(TAG_THRESHOLDING, 1, |
| 380 |
"No dithering or halftoning", |
| 381 |
"Ordered dither or halftone", |
| 382 |
"Randomized dither" |
| 383 |
); |
| 384 |
} |
| 385 |
|
| 386 |
@Nullable |
| 387 |
public String getFillOrderDescription() |
| 388 |
{ |
| 389 |
return getIndexedDescription(TAG_FILL_ORDER, 1, |
| 390 |
"Normal", |
| 391 |
"Reversed" |
| 392 |
); |
| 393 |
} |
| 394 |
|
| 395 |
@Nullable |
| 396 |
public String getOrientationDescription() |
| 397 |
{ |
| 398 |
return super.getOrientationDescription(TAG_ORIENTATION); |
| 399 |
} |
| 400 |
|
| 401 |
@Nullable |
| 402 |
public String getSamplesPerPixelDescription() |
| 403 |
{ |
| 404 |
String value = _directory.getString(TAG_SAMPLES_PER_PIXEL); |
| 405 |
return value == null ? null : value + " samples/pixel"; |
| 406 |
} |
| 407 |
|
| 408 |
@Nullable |
| 409 |
public String getRowsPerStripDescription() |
| 410 |
{ |
| 411 |
final String value = _directory.getString(TAG_ROWS_PER_STRIP); |
| 412 |
return value == null ? null : value + " rows/strip"; |
| 413 |
} |
| 414 |
|
| 415 |
@Nullable |
| 416 |
public String getStripByteCountsDescription() |
| 417 |
{ |
| 418 |
final String value = _directory.getString(TAG_STRIP_BYTE_COUNTS); |
| 419 |
return value == null ? null : value + " bytes"; |
| 420 |
} |
| 421 |
|
| 422 |
@Nullable |
| 423 |
public String getXResolutionDescription() |
| 424 |
{ |
| 425 |
Rational value = _directory.getRational(TAG_X_RESOLUTION); |
| 426 |
if (value == null) |
| 427 |
return null; |
| 428 |
final String unit = getResolutionDescription(); |
| 429 |
return String.format("%s dots per %s", |
| 430 |
value.toSimpleString(_allowDecimalRepresentationOfRationals), |
| 431 |
unit == null ? "unit" : unit.toLowerCase()); |
| 432 |
} |
| 433 |
|
| 434 |
@Nullable |
| 435 |
public String getYResolutionDescription() |
| 436 |
{ |
| 437 |
Rational value = _directory.getRational(TAG_Y_RESOLUTION); |
| 438 |
if (value==null) |
| 439 |
return null; |
| 440 |
final String unit = getResolutionDescription(); |
| 441 |
return String.format("%s dots per %s", |
| 442 |
value.toSimpleString(_allowDecimalRepresentationOfRationals), |
| 443 |
unit == null ? "unit" : unit.toLowerCase()); |
| 444 |
} |
| 445 |
|
| 446 |
@Nullable |
| 447 |
public String getPlanarConfigurationDescription() |
| 448 |
{ |
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
return getIndexedDescription(TAG_PLANAR_CONFIGURATION, |
| 454 |
1, |
| 455 |
"Chunky (contiguous for each subsampling pixel)", |
| 456 |
"Separate (Y-plane/Cb-plane/Cr-plane format)" |
| 457 |
); |
| 458 |
} |
| 459 |
|
| 460 |
@Nullable |
| 461 |
public String getResolutionDescription() |
| 462 |
{ |
| 463 |
|
| 464 |
return getIndexedDescription(TAG_RESOLUTION_UNIT, 1, "(No unit)", "Inch", "cm"); |
| 465 |
} |
| 466 |
|
| 467 |
@Nullable |
| 468 |
public String getJpegProcDescription() |
| 469 |
{ |
| 470 |
Integer value = _directory.getInteger(TAG_JPEG_PROC); |
| 471 |
if (value == null) |
| 472 |
return null; |
| 473 |
switch (value) { |
| 474 |
case 1: return "Baseline"; |
| 475 |
case 14: return "Lossless"; |
| 476 |
default: |
| 477 |
return "Unknown (" + value + ")"; |
| 478 |
} |
| 479 |
} |
| 480 |
|
| 481 |
@Nullable |
| 482 |
public String getYCbCrSubsamplingDescription() |
| 483 |
{ |
| 484 |
int[] positions = _directory.getIntArray(TAG_YCBCR_SUBSAMPLING); |
| 485 |
if (positions == null || positions.length < 2) |
| 486 |
return null; |
| 487 |
if (positions[0] == 2 && positions[1] == 1) { |
| 488 |
return "YCbCr4:2:2"; |
| 489 |
} else if (positions[0] == 2 && positions[1] == 2) { |
| 490 |
return "YCbCr4:2:0"; |
| 491 |
} else { |
| 492 |
return "(Unknown)"; |
| 493 |
} |
| 494 |
} |
| 495 |
|
| 496 |
@Nullable |
| 497 |
public String getYCbCrPositioningDescription() |
| 498 |
{ |
| 499 |
return getIndexedDescription(TAG_YCBCR_POSITIONING, 1, "Center of pixel array", "Datum point"); |
| 500 |
} |
| 501 |
|
| 502 |
@Nullable |
| 503 |
public String getReferenceBlackWhiteDescription() |
| 504 |
{ |
| 505 |
|
| 506 |
|
| 507 |
int[] ints = _directory.getIntArray(TAG_REFERENCE_BLACK_WHITE); |
| 508 |
if (ints==null || ints.length < 6) |
| 509 |
{ |
| 510 |
Object o = _directory.getObject(TAG_REFERENCE_BLACK_WHITE); |
| 511 |
if (o != null && (o instanceof long[])) |
| 512 |
{ |
| 513 |
long[] longs = (long[])o; |
| 514 |
if (longs.length < 6) |
| 515 |
return null; |
| 516 |
|
| 517 |
ints = new int[longs.length]; |
| 518 |
for (int i = 0; i < longs.length; i++) |
| 519 |
ints[i] = (int)longs[i]; |
| 520 |
} |
| 521 |
else |
| 522 |
return null; |
| 523 |
} |
| 524 |
|
| 525 |
int blackR = ints[0]; |
| 526 |
int whiteR = ints[1]; |
| 527 |
int blackG = ints[2]; |
| 528 |
int whiteG = ints[3]; |
| 529 |
int blackB = ints[4]; |
| 530 |
int whiteB = ints[5]; |
| 531 |
return String.format("[%d,%d,%d] [%d,%d,%d]", blackR, blackG, blackB, whiteR, whiteG, whiteB); |
| 532 |
} |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
@Nullable |
| 544 |
public String getCfaPattern2Description() |
| 545 |
{ |
| 546 |
byte[] values = _directory.getByteArray(TAG_CFA_PATTERN_2); |
| 547 |
if (values == null) |
| 548 |
return null; |
| 549 |
|
| 550 |
int[] repeatPattern = _directory.getIntArray(TAG_CFA_REPEAT_PATTERN_DIM); |
| 551 |
if (repeatPattern == null) |
| 552 |
return String.format("Repeat Pattern not found for CFAPattern (%s)", super.getDescription(TAG_CFA_PATTERN_2)); |
| 553 |
|
| 554 |
if (repeatPattern.length == 2 && values.length == (repeatPattern[0] * repeatPattern[1])) |
| 555 |
{ |
| 556 |
int[] intpattern = new int[2 + values.length]; |
| 557 |
intpattern[0] = repeatPattern[0]; |
| 558 |
intpattern[1] = repeatPattern[1]; |
| 559 |
|
| 560 |
for (int i = 0; i < values.length; i++) |
| 561 |
intpattern[i + 2] = values[i] & 0xFF; |
| 562 |
|
| 563 |
return formatCFAPattern(intpattern); |
| 564 |
} |
| 565 |
|
| 566 |
return String.format("Unknown Pattern (%s)", super.getDescription(TAG_CFA_PATTERN_2)); |
| 567 |
} |
| 568 |
|
| 569 |
@Nullable |
| 570 |
private static String formatCFAPattern(@Nullable int[] pattern) |
| 571 |
{ |
| 572 |
if (pattern == null) |
| 573 |
return null; |
| 574 |
if (pattern.length < 2) |
| 575 |
return "<truncated data>"; |
| 576 |
if (pattern[0] == 0 && pattern[1] == 0) |
| 577 |
return "<zero pattern size>"; |
| 578 |
|
| 579 |
int end = 2 + pattern[0] * pattern[1]; |
| 580 |
if (end > pattern.length) |
| 581 |
return "<invalid pattern size>"; |
| 582 |
|
| 583 |
String[] cfaColors = { "Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "White" }; |
| 584 |
|
| 585 |
StringBuilder ret = new StringBuilder(); |
| 586 |
ret.append("["); |
| 587 |
for (int pos = 2; pos < end; pos++) |
| 588 |
{ |
| 589 |
if (pattern[pos] <= cfaColors.length - 1) |
| 590 |
ret.append(cfaColors[pattern[pos]]); |
| 591 |
else |
| 592 |
ret.append("Unknown"); |
| 593 |
|
| 594 |
if ((pos - 2) % pattern[1] == 0) |
| 595 |
ret.append(","); |
| 596 |
else if(pos != end - 1) |
| 597 |
ret.append("]["); |
| 598 |
} |
| 599 |
ret.append("]"); |
| 600 |
|
| 601 |
return ret.toString(); |
| 602 |
} |
| 603 |
|
| 604 |
@Nullable |
| 605 |
public String getExposureTimeDescription() |
| 606 |
{ |
| 607 |
String value = _directory.getString(TAG_EXPOSURE_TIME); |
| 608 |
return value == null ? null : value + " sec"; |
| 609 |
} |
| 610 |
|
| 611 |
@Nullable |
| 612 |
public String getFNumberDescription() |
| 613 |
{ |
| 614 |
Rational value = _directory.getRational(TAG_FNUMBER); |
| 615 |
if (value == null) |
| 616 |
return null; |
| 617 |
return getFStopDescription(value.doubleValue()); |
| 618 |
} |
| 619 |
|
| 620 |
@Nullable |
| 621 |
public String getExposureProgramDescription() |
| 622 |
{ |
| 623 |
return getIndexedDescription(TAG_EXPOSURE_PROGRAM, |
| 624 |
1, |
| 625 |
"Manual control", |
| 626 |
"Program normal", |
| 627 |
"Aperture priority", |
| 628 |
"Shutter priority", |
| 629 |
"Program creative (slow program)", |
| 630 |
"Program action (high-speed program)", |
| 631 |
"Portrait mode", |
| 632 |
"Landscape mode" |
| 633 |
); |
| 634 |
} |
| 635 |
|
| 636 |
@Nullable |
| 637 |
public String getIsoEquivalentDescription() |
| 638 |
{ |
| 639 |
|
| 640 |
Integer isoEquiv = _directory.getInteger(TAG_ISO_EQUIVALENT); |
| 641 |
|
| 642 |
|
| 643 |
return isoEquiv != null |
| 644 |
? Integer.toString(isoEquiv) |
| 645 |
: null; |
| 646 |
} |
| 647 |
|
| 648 |
@Nullable |
| 649 |
public String getSensitivityTypeRangeDescription() |
| 650 |
{ |
| 651 |
return getIndexedDescription(TAG_SENSITIVITY_TYPE, |
| 652 |
"Unknown", |
| 653 |
"Standard Output Sensitivity", |
| 654 |
"Recommended Exposure Index", |
| 655 |
"ISO Speed", |
| 656 |
"Standard Output Sensitivity and Recommended Exposure Index", |
| 657 |
"Standard Output Sensitivity and ISO Speed", |
| 658 |
"Recommended Exposure Index and ISO Speed", |
| 659 |
"Standard Output Sensitivity, Recommended Exposure Index and ISO Speed" |
| 660 |
); |
| 661 |
} |
| 662 |
|
| 663 |
@Nullable |
| 664 |
public String getExifVersionDescription() |
| 665 |
{ |
| 666 |
return getVersionBytesDescription(TAG_EXIF_VERSION, 2); |
| 667 |
} |
| 668 |
|
| 669 |
@Nullable |
| 670 |
public String getComponentConfigurationDescription() |
| 671 |
{ |
| 672 |
int[] components = _directory.getIntArray(TAG_COMPONENTS_CONFIGURATION); |
| 673 |
if (components == null) |
| 674 |
return null; |
| 675 |
String[] componentStrings = {"", "Y", "Cb", "Cr", "R", "G", "B"}; |
| 676 |
StringBuilder componentConfig = new StringBuilder(); |
| 677 |
for (int i = 0; i < Math.min(4, components.length); i++) { |
| 678 |
int j = components[i]; |
| 679 |
if (j > 0 && j < componentStrings.length) { |
| 680 |
componentConfig.append(componentStrings[j]); |
| 681 |
} |
| 682 |
} |
| 683 |
return componentConfig.toString(); |
| 684 |
} |
| 685 |
|
| 686 |
@Nullable |
| 687 |
public String getCompressedAverageBitsPerPixelDescription() |
| 688 |
{ |
| 689 |
Rational value = _directory.getRational(TAG_COMPRESSED_AVERAGE_BITS_PER_PIXEL); |
| 690 |
if (value == null) |
| 691 |
return null; |
| 692 |
String ratio = value.toSimpleString(_allowDecimalRepresentationOfRationals); |
| 693 |
return value.isInteger() && value.intValue() == 1 |
| 694 |
? ratio + " bit/pixel" |
| 695 |
: ratio + " bits/pixel"; |
| 696 |
} |
| 697 |
|
| 698 |
@Nullable |
| 699 |
public String getShutterSpeedDescription() |
| 700 |
{ |
| 701 |
return super.getShutterSpeedDescription(TAG_SHUTTER_SPEED); |
| 702 |
} |
| 703 |
|
| 704 |
@Nullable |
| 705 |
public String getApertureValueDescription() |
| 706 |
{ |
| 707 |
Double aperture = _directory.getDoubleObject(TAG_APERTURE); |
| 708 |
if (aperture == null) |
| 709 |
return null; |
| 710 |
double fStop = PhotographicConversions.apertureToFStop(aperture); |
| 711 |
return getFStopDescription(fStop); |
| 712 |
} |
| 713 |
|
| 714 |
@Nullable |
| 715 |
public String getBrightnessValueDescription() |
| 716 |
{ |
| 717 |
Rational value = _directory.getRational(TAG_BRIGHTNESS_VALUE); |
| 718 |
if (value == null) |
| 719 |
return null; |
| 720 |
if (value.getNumerator() == 0xFFFFFFFFL) |
| 721 |
return "Unknown"; |
| 722 |
DecimalFormat formatter = new DecimalFormat("0.0##"); |
| 723 |
return formatter.format(value.doubleValue()); |
| 724 |
} |
| 725 |
|
| 726 |
@Nullable |
| 727 |
public String getExposureBiasDescription() |
| 728 |
{ |
| 729 |
Rational value = _directory.getRational(TAG_EXPOSURE_BIAS); |
| 730 |
if (value == null) |
| 731 |
return null; |
| 732 |
return value.toSimpleString(true) + " EV"; |
| 733 |
} |
| 734 |
|
| 735 |
@Nullable |
| 736 |
public String getMaxApertureValueDescription() |
| 737 |
{ |
| 738 |
Double aperture = _directory.getDoubleObject(TAG_MAX_APERTURE); |
| 739 |
if (aperture == null) |
| 740 |
return null; |
| 741 |
double fStop = PhotographicConversions.apertureToFStop(aperture); |
| 742 |
return getFStopDescription(fStop); |
| 743 |
} |
| 744 |
|
| 745 |
@Nullable |
| 746 |
public String getSubjectDistanceDescription() |
| 747 |
{ |
| 748 |
Rational value = _directory.getRational(TAG_SUBJECT_DISTANCE); |
| 749 |
if (value == null) |
| 750 |
return null; |
| 751 |
if (value.getNumerator() == 0xFFFFFFFFL) |
| 752 |
return "Infinity"; |
| 753 |
if (value.getNumerator() == 0) |
| 754 |
return "Unknown"; |
| 755 |
DecimalFormat formatter = new DecimalFormat("0.0##"); |
| 756 |
return formatter.format(value.doubleValue()) + " metres"; |
| 757 |
} |
| 758 |
|
| 759 |
@Nullable |
| 760 |
public String getMeteringModeDescription() |
| 761 |
{ |
| 762 |
|
| 763 |
|
| 764 |
Integer value = _directory.getInteger(TAG_METERING_MODE); |
| 765 |
if (value == null) |
| 766 |
return null; |
| 767 |
switch (value) { |
| 768 |
case 0: return "Unknown"; |
| 769 |
case 1: return "Average"; |
| 770 |
case 2: return "Center weighted average"; |
| 771 |
case 3: return "Spot"; |
| 772 |
case 4: return "Multi-spot"; |
| 773 |
case 5: return "Multi-segment"; |
| 774 |
case 6: return "Partial"; |
| 775 |
case 255: return "(Other)"; |
| 776 |
default: |
| 777 |
return "Unknown (" + value + ")"; |
| 778 |
} |
| 779 |
} |
| 780 |
|
| 781 |
@Nullable |
| 782 |
public String getWhiteBalanceDescription() |
| 783 |
{ |
| 784 |
final Integer value = _directory.getInteger(TAG_WHITE_BALANCE); |
| 785 |
if (value == null) |
| 786 |
return null; |
| 787 |
return getWhiteBalanceDescription(value); |
| 788 |
} |
| 789 |
|
| 790 |
static String getWhiteBalanceDescription(int value) |
| 791 |
{ |
| 792 |
|
| 793 |
|
| 794 |
switch (value) { |
| 795 |
case 0: return "Unknown"; |
| 796 |
case 1: return "Daylight"; |
| 797 |
case 2: return "Florescent"; |
| 798 |
case 3: return "Tungsten (Incandescent)"; |
| 799 |
case 4: return "Flash"; |
| 800 |
case 9: return "Fine Weather"; |
| 801 |
case 10: return "Cloudy"; |
| 802 |
case 11: return "Shade"; |
| 803 |
case 12: return "Daylight Fluorescent"; |
| 804 |
case 13: return "Day White Fluorescent"; |
| 805 |
case 14: return "Cool White Fluorescent"; |
| 806 |
case 15: return "White Fluorescent"; |
| 807 |
case 16: return "Warm White Fluorescent"; |
| 808 |
case 17: return "Standard light A"; |
| 809 |
case 18: return "Standard light B"; |
| 810 |
case 19: return "Standard light C"; |
| 811 |
case 20: return "D55"; |
| 812 |
case 21: return "D65"; |
| 813 |
case 22: return "D75"; |
| 814 |
case 23: return "D50"; |
| 815 |
case 24: return "ISO Studio Tungsten"; |
| 816 |
case 255: return "Other"; |
| 817 |
default: |
| 818 |
return "Unknown (" + value + ")"; |
| 819 |
} |
| 820 |
} |
| 821 |
|
| 822 |
@Nullable |
| 823 |
public String getFlashDescription() |
| 824 |
{ |
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
final Integer value = _directory.getInteger(TAG_FLASH); |
| 837 |
|
| 838 |
if (value == null) |
| 839 |
return null; |
| 840 |
|
| 841 |
StringBuilder sb = new StringBuilder(); |
| 842 |
|
| 843 |
if ((value & 0x1) != 0) |
| 844 |
sb.append("Flash fired"); |
| 845 |
else |
| 846 |
sb.append("Flash did not fire"); |
| 847 |
|
| 848 |
|
| 849 |
if ((value & 0x4) != 0) { |
| 850 |
if ((value & 0x2) != 0) |
| 851 |
sb.append(", return detected"); |
| 852 |
else |
| 853 |
sb.append(", return not detected"); |
| 854 |
} |
| 855 |
|
| 856 |
|
| 857 |
if ((value & 0x10) != 0 && (value & 0x0F) != 0) |
| 858 |
sb.append(", auto"); |
| 859 |
|
| 860 |
if ((value & 0x40) != 0) |
| 861 |
sb.append(", red-eye reduction"); |
| 862 |
|
| 863 |
return sb.toString(); |
| 864 |
} |
| 865 |
|
| 866 |
@Nullable |
| 867 |
public String getFocalLengthDescription() |
| 868 |
{ |
| 869 |
Rational value = _directory.getRational(TAG_FOCAL_LENGTH); |
| 870 |
return value == null ? null : getFocalLengthDescription(value.doubleValue()); |
| 871 |
} |
| 872 |
|
| 873 |
@Nullable |
| 874 |
public String getUserCommentDescription() |
| 875 |
{ |
| 876 |
return getEncodedTextDescription(TAG_USER_COMMENT); |
| 877 |
} |
| 878 |
|
| 879 |
@Nullable |
| 880 |
public String getTemperatureDescription() |
| 881 |
{ |
| 882 |
Rational value = _directory.getRational(TAG_TEMPERATURE); |
| 883 |
if (value == null) |
| 884 |
return null; |
| 885 |
if (value.getDenominator() == 0xFFFFFFFFL) |
| 886 |
return "Unknown"; |
| 887 |
DecimalFormat formatter = new DecimalFormat("0.0"); |
| 888 |
return formatter.format(value.doubleValue()) + " °C"; |
| 889 |
} |
| 890 |
|
| 891 |
@Nullable |
| 892 |
public String getHumidityDescription() |
| 893 |
{ |
| 894 |
Rational value = _directory.getRational(TAG_HUMIDITY); |
| 895 |
if (value == null) |
| 896 |
return null; |
| 897 |
if (value.getDenominator() == 0xFFFFFFFFL) |
| 898 |
return "Unknown"; |
| 899 |
DecimalFormat formatter = new DecimalFormat("0.0"); |
| 900 |
return formatter.format(value.doubleValue()) + " %"; |
| 901 |
} |
| 902 |
|
| 903 |
@Nullable |
| 904 |
public String getPressureDescription() |
| 905 |
{ |
| 906 |
Rational value = _directory.getRational(TAG_PRESSURE); |
| 907 |
if (value == null) |
| 908 |
return null; |
| 909 |
if (value.getDenominator() == 0xFFFFFFFFL) |
| 910 |
return "Unknown"; |
| 911 |
DecimalFormat formatter = new DecimalFormat("0.0"); |
| 912 |
return formatter.format(value.doubleValue()) + " hPa"; |
| 913 |
} |
| 914 |
|
| 915 |
@Nullable |
| 916 |
public String getWaterDepthDescription() |
| 917 |
{ |
| 918 |
Rational value = _directory.getRational(TAG_WATER_DEPTH); |
| 919 |
if (value == null) |
| 920 |
return null; |
| 921 |
if (value.getDenominator() == 0xFFFFFFFFL) |
| 922 |
return "Unknown"; |
| 923 |
DecimalFormat formatter = new DecimalFormat("0.0##"); |
| 924 |
return formatter.format(value.doubleValue()) + " metres"; |
| 925 |
} |
| 926 |
|
| 927 |
@Nullable |
| 928 |
public String getAccelerationDescription() |
| 929 |
{ |
| 930 |
Rational value = _directory.getRational(TAG_ACCELERATION); |
| 931 |
if (value == null) |
| 932 |
return null; |
| 933 |
if (value.getDenominator() == 0xFFFFFFFFL) |
| 934 |
return "Unknown"; |
| 935 |
DecimalFormat formatter = new DecimalFormat("0.0##"); |
| 936 |
return formatter.format(value.doubleValue()) + " mGal"; |
| 937 |
} |
| 938 |
|
| 939 |
@Nullable |
| 940 |
public String getCameraElevationAngleDescription() |
| 941 |
{ |
| 942 |
Rational value = _directory.getRational(TAG_CAMERA_ELEVATION_ANGLE); |
| 943 |
if (value == null) |
| 944 |
return null; |
| 945 |
if (value.getDenominator() == 0xFFFFFFFFL) |
| 946 |
return "Unknown"; |
| 947 |
DecimalFormat formatter = new DecimalFormat("0.##"); |
| 948 |
return formatter.format(value.doubleValue()) + " degrees"; |
| 949 |
} |
| 950 |
|
| 951 |
|
| 952 |
@Nullable |
| 953 |
private String getUnicodeDescription(int tag) |
| 954 |
{ |
| 955 |
byte[] bytes = _directory.getByteArray(tag); |
| 956 |
if (bytes == null) |
| 957 |
return null; |
| 958 |
try { |
| 959 |
|
| 960 |
return new String(bytes, "UTF-16LE").trim(); |
| 961 |
} catch (UnsupportedEncodingException ex) { |
| 962 |
return null; |
| 963 |
} |
| 964 |
} |
| 965 |
|
| 966 |
@Nullable |
| 967 |
public String getWindowsTitleDescription() |
| 968 |
{ |
| 969 |
return getUnicodeDescription(TAG_WIN_TITLE); |
| 970 |
} |
| 971 |
|
| 972 |
@Nullable |
| 973 |
public String getWindowsCommentDescription() |
| 974 |
{ |
| 975 |
return getUnicodeDescription(TAG_WIN_COMMENT); |
| 976 |
} |
| 977 |
|
| 978 |
@Nullable |
| 979 |
public String getWindowsAuthorDescription() |
| 980 |
{ |
| 981 |
return getUnicodeDescription(TAG_WIN_AUTHOR); |
| 982 |
} |
| 983 |
|
| 984 |
@Nullable |
| 985 |
public String getWindowsKeywordsDescription() |
| 986 |
{ |
| 987 |
return getUnicodeDescription(TAG_WIN_KEYWORDS); |
| 988 |
} |
| 989 |
|
| 990 |
@Nullable |
| 991 |
public String getWindowsSubjectDescription() |
| 992 |
{ |
| 993 |
return getUnicodeDescription(TAG_WIN_SUBJECT); |
| 994 |
} |
| 995 |
|
| 996 |
@Nullable |
| 997 |
public String getFlashPixVersionDescription() |
| 998 |
{ |
| 999 |
return getVersionBytesDescription(TAG_FLASHPIX_VERSION, 2); |
| 1000 |
} |
| 1001 |
|
| 1002 |
@Nullable |
| 1003 |
public String getColorSpaceDescription() |
| 1004 |
{ |
| 1005 |
final Integer value = _directory.getInteger(TAG_COLOR_SPACE); |
| 1006 |
if (value == null) |
| 1007 |
return null; |
| 1008 |
if (value == 1) |
| 1009 |
return "sRGB"; |
| 1010 |
if (value == 65535) |
| 1011 |
return "Undefined"; |
| 1012 |
return "Unknown (" + value + ")"; |
| 1013 |
} |
| 1014 |
|
| 1015 |
@Nullable |
| 1016 |
public String getExifImageWidthDescription() |
| 1017 |
{ |
| 1018 |
final Integer value = _directory.getInteger(TAG_EXIF_IMAGE_WIDTH); |
| 1019 |
return value == null ? null : value + " pixels"; |
| 1020 |
} |
| 1021 |
|
| 1022 |
@Nullable |
| 1023 |
public String getExifImageHeightDescription() |
| 1024 |
{ |
| 1025 |
final Integer value = _directory.getInteger(TAG_EXIF_IMAGE_HEIGHT); |
| 1026 |
return value == null ? null : value + " pixels"; |
| 1027 |
} |
| 1028 |
|
| 1029 |
@Nullable |
| 1030 |
public String getFocalPlaneXResolutionDescription() |
| 1031 |
{ |
| 1032 |
Rational rational = _directory.getRational(TAG_FOCAL_PLANE_X_RESOLUTION); |
| 1033 |
if (rational == null) |
| 1034 |
return null; |
| 1035 |
final String unit = getFocalPlaneResolutionUnitDescription(); |
| 1036 |
return rational.getReciprocal().toSimpleString(_allowDecimalRepresentationOfRationals) |
| 1037 |
+ (unit == null ? "" : " " + unit.toLowerCase()); |
| 1038 |
} |
| 1039 |
|
| 1040 |
@Nullable |
| 1041 |
public String getFocalPlaneYResolutionDescription() |
| 1042 |
{ |
| 1043 |
Rational rational = _directory.getRational(TAG_FOCAL_PLANE_Y_RESOLUTION); |
| 1044 |
if (rational == null) |
| 1045 |
return null; |
| 1046 |
final String unit = getFocalPlaneResolutionUnitDescription(); |
| 1047 |
return rational.getReciprocal().toSimpleString(_allowDecimalRepresentationOfRationals) |
| 1048 |
+ (unit == null ? "" : " " + unit.toLowerCase()); |
| 1049 |
} |
| 1050 |
|
| 1051 |
@Nullable |
| 1052 |
public String getFocalPlaneResolutionUnitDescription() |
| 1053 |
{ |
| 1054 |
|
| 1055 |
|
| 1056 |
return getIndexedDescription(TAG_FOCAL_PLANE_RESOLUTION_UNIT, |
| 1057 |
1, |
| 1058 |
"(No unit)", |
| 1059 |
"Inches", |
| 1060 |
"cm" |
| 1061 |
); |
| 1062 |
} |
| 1063 |
|
| 1064 |
@Nullable |
| 1065 |
public String getSensingMethodDescription() |
| 1066 |
{ |
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
return getIndexedDescription(TAG_SENSING_METHOD, |
| 1071 |
1, |
| 1072 |
"(Not defined)", |
| 1073 |
"One-chip color area sensor", |
| 1074 |
"Two-chip color area sensor", |
| 1075 |
"Three-chip color area sensor", |
| 1076 |
"Color sequential area sensor", |
| 1077 |
null, |
| 1078 |
"Trilinear sensor", |
| 1079 |
"Color sequential linear sensor" |
| 1080 |
); |
| 1081 |
} |
| 1082 |
|
| 1083 |
@Nullable |
| 1084 |
public String getFileSourceDescription() |
| 1085 |
{ |
| 1086 |
return getIndexedDescription(TAG_FILE_SOURCE, |
| 1087 |
1, |
| 1088 |
"Film Scanner", |
| 1089 |
"Reflection Print Scanner", |
| 1090 |
"Digital Still Camera (DSC)" |
| 1091 |
); |
| 1092 |
} |
| 1093 |
|
| 1094 |
@Nullable |
| 1095 |
public String getSceneTypeDescription() |
| 1096 |
{ |
| 1097 |
return getIndexedDescription(TAG_SCENE_TYPE, |
| 1098 |
1, |
| 1099 |
"Directly photographed image" |
| 1100 |
); |
| 1101 |
} |
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
@Nullable |
| 1114 |
public String getCfaPatternDescription() |
| 1115 |
{ |
| 1116 |
return formatCFAPattern(decodeCfaPattern(TAG_CFA_PATTERN)); |
| 1117 |
} |
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
@Nullable |
| 1131 |
private int[] decodeCfaPattern(int tagType) |
| 1132 |
{ |
| 1133 |
int[] ret; |
| 1134 |
|
| 1135 |
byte[] values = _directory.getByteArray(tagType); |
| 1136 |
if (values == null) |
| 1137 |
return null; |
| 1138 |
|
| 1139 |
if (values.length < 4) |
| 1140 |
{ |
| 1141 |
ret = new int[values.length]; |
| 1142 |
for (int i = 0; i < values.length; i++) |
| 1143 |
ret[i] = values[i]; |
| 1144 |
return ret; |
| 1145 |
} |
| 1146 |
|
| 1147 |
ret = new int[values.length - 2]; |
| 1148 |
|
| 1149 |
try { |
| 1150 |
ByteArrayReader reader = new ByteArrayReader(values); |
| 1151 |
|
| 1152 |
|
| 1153 |
short item0 = reader.getInt16(0); |
| 1154 |
short item1 = reader.getInt16(2); |
| 1155 |
|
| 1156 |
boolean copyArray = false; |
| 1157 |
int end = 2 + item0 * item1; |
| 1158 |
if (end > values.length) |
| 1159 |
{ |
| 1160 |
|
| 1161 |
reader.setMotorolaByteOrder(!reader.isMotorolaByteOrder()); |
| 1162 |
item0 = reader.getInt16(0); |
| 1163 |
item1 = reader.getInt16(2); |
| 1164 |
|
| 1165 |
if (values.length >= (2 + item0 * item1)) |
| 1166 |
copyArray = true; |
| 1167 |
} |
| 1168 |
else |
| 1169 |
copyArray = true; |
| 1170 |
|
| 1171 |
if(copyArray) |
| 1172 |
{ |
| 1173 |
ret[0] = item0; |
| 1174 |
ret[1] = item1; |
| 1175 |
|
| 1176 |
for (int i = 4; i < values.length; i++) |
| 1177 |
ret[i - 2] = reader.getInt8(i); |
| 1178 |
} |
| 1179 |
} catch (IOException ex) { |
| 1180 |
_directory.addError("IO exception processing data: " + ex.getMessage()); |
| 1181 |
} |
| 1182 |
|
| 1183 |
return ret; |
| 1184 |
} |
| 1185 |
|
| 1186 |
@Nullable |
| 1187 |
public String getCustomRenderedDescription() |
| 1188 |
{ |
| 1189 |
return getIndexedDescription(TAG_CUSTOM_RENDERED, |
| 1190 |
"Normal process", |
| 1191 |
"Custom process" |
| 1192 |
); |
| 1193 |
} |
| 1194 |
|
| 1195 |
@Nullable |
| 1196 |
public String getExposureModeDescription() |
| 1197 |
{ |
| 1198 |
return getIndexedDescription(TAG_EXPOSURE_MODE, |
| 1199 |
"Auto exposure", |
| 1200 |
"Manual exposure", |
| 1201 |
"Auto bracket" |
| 1202 |
); |
| 1203 |
} |
| 1204 |
|
| 1205 |
@Nullable |
| 1206 |
public String getWhiteBalanceModeDescription() |
| 1207 |
{ |
| 1208 |
return getIndexedDescription(TAG_WHITE_BALANCE_MODE, |
| 1209 |
"Auto white balance", |
| 1210 |
"Manual white balance" |
| 1211 |
); |
| 1212 |
} |
| 1213 |
|
| 1214 |
@Nullable |
| 1215 |
public String getDigitalZoomRatioDescription() |
| 1216 |
{ |
| 1217 |
Rational value = _directory.getRational(TAG_DIGITAL_ZOOM_RATIO); |
| 1218 |
return value == null |
| 1219 |
? null |
| 1220 |
: value.getNumerator() == 0 |
| 1221 |
? "Digital zoom not used" |
| 1222 |
: new DecimalFormat("0.#").format(value.doubleValue()); |
| 1223 |
} |
| 1224 |
|
| 1225 |
@Nullable |
| 1226 |
public String get35mmFilmEquivFocalLengthDescription() |
| 1227 |
{ |
| 1228 |
Integer value = _directory.getInteger(TAG_35MM_FILM_EQUIV_FOCAL_LENGTH); |
| 1229 |
return value == null |
| 1230 |
? null |
| 1231 |
: value == 0 |
| 1232 |
? "Unknown" |
| 1233 |
: getFocalLengthDescription(value); |
| 1234 |
} |
| 1235 |
|
| 1236 |
@Nullable |
| 1237 |
public String getSceneCaptureTypeDescription() |
| 1238 |
{ |
| 1239 |
return getIndexedDescription(TAG_SCENE_CAPTURE_TYPE, |
| 1240 |
"Standard", |
| 1241 |
"Landscape", |
| 1242 |
"Portrait", |
| 1243 |
"Night scene" |
| 1244 |
); |
| 1245 |
} |
| 1246 |
|
| 1247 |
@Nullable |
| 1248 |
public String getGainControlDescription() |
| 1249 |
{ |
| 1250 |
return getIndexedDescription(TAG_GAIN_CONTROL, |
| 1251 |
"None", |
| 1252 |
"Low gain up", |
| 1253 |
"Low gain down", |
| 1254 |
"High gain up", |
| 1255 |
"High gain down" |
| 1256 |
); |
| 1257 |
} |
| 1258 |
|
| 1259 |
@Nullable |
| 1260 |
public String getContrastDescription() |
| 1261 |
{ |
| 1262 |
return getIndexedDescription(TAG_CONTRAST, |
| 1263 |
"None", |
| 1264 |
"Soft", |
| 1265 |
"Hard" |
| 1266 |
); |
| 1267 |
} |
| 1268 |
|
| 1269 |
@Nullable |
| 1270 |
public String getSaturationDescription() |
| 1271 |
{ |
| 1272 |
return getIndexedDescription(TAG_SATURATION, |
| 1273 |
"None", |
| 1274 |
"Low saturation", |
| 1275 |
"High saturation" |
| 1276 |
); |
| 1277 |
} |
| 1278 |
|
| 1279 |
@Nullable |
| 1280 |
public String getSharpnessDescription() |
| 1281 |
{ |
| 1282 |
return getIndexedDescription(TAG_SHARPNESS, |
| 1283 |
"None", |
| 1284 |
"Low", |
| 1285 |
"Hard" |
| 1286 |
); |
| 1287 |
} |
| 1288 |
|
| 1289 |
@Nullable |
| 1290 |
public String getSubjectDistanceRangeDescription() |
| 1291 |
{ |
| 1292 |
return getIndexedDescription(TAG_SUBJECT_DISTANCE_RANGE, |
| 1293 |
"Unknown", |
| 1294 |
"Macro", |
| 1295 |
"Close view", |
| 1296 |
"Distant view" |
| 1297 |
); |
| 1298 |
} |
| 1299 |
|
| 1300 |
@Nullable |
| 1301 |
public String getLensSpecificationDescription() |
| 1302 |
{ |
| 1303 |
return getLensSpecificationDescription(TAG_LENS_SPECIFICATION); |
| 1304 |
} |
| 1305 |
|
| 1306 |
@Nullable |
| 1307 |
public String getExtraSamplesDescription() |
| 1308 |
{ |
| 1309 |
return getIndexedDescription(TAG_EXTRA_SAMPLES, |
| 1310 |
"Unspecified", |
| 1311 |
"Associated alpha", |
| 1312 |
"Unassociated alpha" |
| 1313 |
); |
| 1314 |
} |
| 1315 |
|
| 1316 |
@Nullable |
| 1317 |
public String getSampleFormatDescription() |
| 1318 |
{ |
| 1319 |
int[] values = _directory.getIntArray(TAG_SAMPLE_FORMAT); |
| 1320 |
|
| 1321 |
if (values == null) |
| 1322 |
return null; |
| 1323 |
|
| 1324 |
StringBuilder sb = new StringBuilder(); |
| 1325 |
|
| 1326 |
for (int value : values) { |
| 1327 |
if (sb.length() != 0) |
| 1328 |
sb.append(", "); |
| 1329 |
switch (value){ |
| 1330 |
case 1: sb.append("Unsigned"); break; |
| 1331 |
case 2: sb.append("Signed"); break; |
| 1332 |
case 3: sb.append("Float"); break; |
| 1333 |
case 4: sb.append("Undefined"); break; |
| 1334 |
case 5: sb.append("Complex int"); break; |
| 1335 |
case 6: sb.append("Complex float"); break; |
| 1336 |
default: sb.append("Unknown (").append(value).append(")"); break; |
| 1337 |
} |
| 1338 |
} |
| 1339 |
|
| 1340 |
return sb.toString(); |
| 1341 |
} |
| 1342 |
} |