Changeset 13061 in josm for trunk/src/com/drew/metadata/exif/makernotes/PanasonicMakernoteDescriptor.java
- Timestamp:
- 2017-10-30T22:46:09+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/makernotes/PanasonicMakernoteDescriptor.java
r10862 r13061 1 1 /* 2 * Copyright 2002-201 6Drew Noakes2 * Copyright 2002-2017 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 22 22 23 23 import com.drew.lang.ByteArrayReader; 24 import com.drew.lang.Charsets; 24 25 import com.drew.lang.RandomAccessReader; 25 26 import com.drew.lang.annotations.NotNull; … … 29 30 import com.drew.metadata.TagDescriptor; 30 31 32 import java.text.DecimalFormat; 31 33 import java.io.IOException; 32 34 … … 45 47 * @author Philipp Sandhaus 46 48 */ 49 @SuppressWarnings("WeakerAccess") 47 50 public class PanasonicMakernoteDescriptor extends TagDescriptor<PanasonicMakernoteDirectory> 48 51 { … … 109 112 case TAG_TRANSFORM: 110 113 return getTransformDescription(); 111 112 114 case TAG_TRANSFORM_1: 115 return getTransform1Description(); 113 116 case TAG_INTELLIGENT_EXPOSURE: 114 117 return getIntelligentExposureDescription(); … … 127 130 case TAG_FACE_RECOGNITION_INFO: 128 131 return getRecognizedFacesDescription(); 129 case TAG_PRINT_IMAGE_MATCHING_INFO:130 return getPrintImageMatchingInfoDescription();131 132 case TAG_SCENE_MODE: 132 133 return getSceneModeDescription(); … … 134 135 return getFlashFiredDescription(); 135 136 case TAG_TEXT_STAMP: 136 137 138 139 140 141 142 137 return getTextStampDescription(); 138 case TAG_TEXT_STAMP_1: 139 return getTextStamp1Description(); 140 case TAG_TEXT_STAMP_2: 141 return getTextStamp2Description(); 142 case TAG_TEXT_STAMP_3: 143 return getTextStamp3Description(); 143 144 case TAG_MAKERNOTE_VERSION: 144 145 return getMakernoteVersionDescription(); … … 148 149 return getInternalSerialNumberDescription(); 149 150 case TAG_TITLE: 150 return getTitleDescription(); 151 case TAG_BABY_NAME: 152 return getBabyNameDescription(); 153 case TAG_LOCATION: 154 return getLocationDescription(); 155 case TAG_BABY_AGE: 156 return getBabyAgeDescription(); 157 case TAG_BABY_AGE_1: 158 return getBabyAge1Description(); 159 default: 151 return getTitleDescription(); 152 case TAG_BRACKET_SETTINGS: 153 return getBracketSettingsDescription(); 154 case TAG_FLASH_CURTAIN: 155 return getFlashCurtainDescription(); 156 case TAG_LONG_EXPOSURE_NOISE_REDUCTION: 157 return getLongExposureNoiseReductionDescription(); 158 case TAG_BABY_NAME: 159 return getBabyNameDescription(); 160 case TAG_LOCATION: 161 return getLocationDescription(); 162 163 case TAG_LENS_FIRMWARE_VERSION: 164 return getLensFirmwareVersionDescription(); 165 case TAG_INTELLIGENT_D_RANGE: 166 return getIntelligentDRangeDescription(); 167 case TAG_CLEAR_RETOUCH: 168 return getClearRetouchDescription(); 169 case TAG_PHOTO_STYLE: 170 return getPhotoStyleDescription(); 171 case TAG_SHADING_COMPENSATION: 172 return getShadingCompensationDescription(); 173 174 case TAG_ACCELEROMETER_Z: 175 return getAccelerometerZDescription(); 176 case TAG_ACCELEROMETER_X: 177 return getAccelerometerXDescription(); 178 case TAG_ACCELEROMETER_Y: 179 return getAccelerometerYDescription(); 180 case TAG_CAMERA_ORIENTATION: 181 return getCameraOrientationDescription(); 182 case TAG_ROLL_ANGLE: 183 return getRollAngleDescription(); 184 case TAG_PITCH_ANGLE: 185 return getPitchAngleDescription(); 186 case TAG_SWEEP_PANORAMA_DIRECTION: 187 return getSweepPanoramaDirectionDescription(); 188 case TAG_TIMER_RECORDING: 189 return getTimerRecordingDescription(); 190 case TAG_HDR: 191 return getHDRDescription(); 192 case TAG_SHUTTER_TYPE: 193 return getShutterTypeDescription(); 194 case TAG_TOUCH_AE: 195 return getTouchAeDescription(); 196 197 case TAG_BABY_AGE: 198 return getBabyAgeDescription(); 199 case TAG_BABY_AGE_1: 200 return getBabyAge1Description(); 201 default: 160 202 return super.getDescription(tagType); 161 203 } 162 }163 164 @Nullable165 public String getPrintImageMatchingInfoDescription()166 {167 return getByteLengthDescription(TAG_PRINT_IMAGE_MATCHING_INFO);168 204 } 169 205 … … 279 315 280 316 @Nullable 317 private static String trim(@Nullable String s) 318 { 319 return s == null ? null : s.trim(); 320 } 321 322 @Nullable 281 323 public String getCountryDescription() 282 324 { 283 return getAsciiStringFromBytes(TAG_COUNTRY);325 return trim(getStringFromBytes(TAG_COUNTRY, Charsets.UTF_8)); 284 326 } 285 327 … … 287 329 public String getStateDescription() 288 330 { 289 return getAsciiStringFromBytes(TAG_STATE);331 return trim(getStringFromBytes(TAG_STATE, Charsets.UTF_8)); 290 332 } 291 333 … … 293 335 public String getCityDescription() 294 336 { 295 return getAsciiStringFromBytes(TAG_CITY);337 return trim(getStringFromBytes(TAG_CITY, Charsets.UTF_8)); 296 338 } 297 339 … … 299 341 public String getLandmarkDescription() 300 342 { 301 return getAsciiStringFromBytes(TAG_LANDMARK);302 } 303 304 343 return trim(getStringFromBytes(TAG_LANDMARK, Charsets.UTF_8)); 344 } 345 346 @Nullable 305 347 public String getTitleDescription() 306 348 { 307 return getAsciiStringFromBytes(TAG_TITLE); 308 } 309 310 @Nullable 349 return trim(getStringFromBytes(TAG_TITLE, Charsets.UTF_8)); 350 } 351 352 @Nullable 353 public String getBracketSettingsDescription() 354 { 355 return getIndexedDescription(TAG_BRACKET_SETTINGS, 356 "No Bracket", "3 Images, Sequence 0/-/+", "3 Images, Sequence -/0/+", "5 Images, Sequence 0/-/+", 357 "5 Images, Sequence -/0/+", "7 Images, Sequence 0/-/+", "7 Images, Sequence -/0/+"); 358 } 359 360 @Nullable 361 public String getFlashCurtainDescription() 362 { 363 return getIndexedDescription(TAG_FLASH_CURTAIN, 364 "n/a", "1st", "2nd"); 365 } 366 367 @Nullable 368 public String getLongExposureNoiseReductionDescription() 369 { 370 return getIndexedDescription(TAG_LONG_EXPOSURE_NOISE_REDUCTION, 1, 371 "Off", "On"); 372 } 373 374 @Nullable 375 public String getLensFirmwareVersionDescription() 376 { 377 // lens version has 4 parts separated by periods 378 byte[] bytes = _directory.getByteArray(TAG_LENS_FIRMWARE_VERSION); 379 if (bytes == null) 380 return null; 381 382 StringBuilder sb = new StringBuilder(); 383 for (int i = 0; i < bytes.length; i++) { 384 sb.append(bytes[i]); 385 if (i < bytes.length - 1) 386 sb.append("."); 387 } 388 return sb.toString(); 389 //return string.Join(".", bytes.Select(b => b.ToString()).ToArray()); 390 } 391 392 @Nullable 393 public String getIntelligentDRangeDescription() 394 { 395 return getIndexedDescription(TAG_INTELLIGENT_D_RANGE, 396 "Off", "Low", "Standard", "High"); 397 } 398 399 @Nullable 400 public String getClearRetouchDescription() 401 { 402 return getIndexedDescription(TAG_CLEAR_RETOUCH, 403 "Off", "On"); 404 405 } 406 407 @Nullable 408 public String getPhotoStyleDescription() 409 { 410 return getIndexedDescription(TAG_PHOTO_STYLE, 411 "Auto", "Standard or Custom", "Vivid", "Natural", "Monochrome", "Scenery", "Portrait"); 412 } 413 414 @Nullable 415 public String getShadingCompensationDescription() 416 { 417 return getIndexedDescription(TAG_SHADING_COMPENSATION, 418 "Off", "On"); 419 } 420 421 @Nullable 422 public String getAccelerometerZDescription() 423 { 424 Integer value = _directory.getInteger(TAG_ACCELEROMETER_Z); 425 if (value == null) 426 return null; 427 428 // positive is acceleration upwards 429 return String.valueOf(value.shortValue()); 430 } 431 432 @Nullable 433 public String getAccelerometerXDescription() 434 { 435 Integer value = _directory.getInteger(TAG_ACCELEROMETER_X); 436 if (value == null) 437 return null; 438 439 // positive is acceleration to the left 440 return String.valueOf(value.shortValue()); 441 } 442 443 @Nullable 444 public String getAccelerometerYDescription() 445 { 446 Integer value = _directory.getInteger(TAG_ACCELEROMETER_Y); 447 if (value == null) 448 return null; 449 450 // positive is acceleration backwards 451 return String.valueOf(value.shortValue()); 452 } 453 454 @Nullable 455 public String getCameraOrientationDescription() 456 { 457 return getIndexedDescription(TAG_CAMERA_ORIENTATION, 458 "Normal", "Rotate CW", "Rotate 180", "Rotate CCW", "Tilt Upwards", "Tile Downwards"); 459 } 460 461 @Nullable 462 public String getRollAngleDescription() 463 { 464 Integer value = _directory.getInteger(TAG_ROLL_ANGLE); 465 if (value == null) 466 return null; 467 468 DecimalFormat format = new DecimalFormat("0.#"); 469 // converted to degrees of clockwise camera rotation 470 return format.format(value.shortValue() / 10.0); 471 } 472 473 @Nullable 474 public String getPitchAngleDescription() 475 { 476 Integer value = _directory.getInteger(TAG_PITCH_ANGLE); 477 if (value == null) 478 return null; 479 480 DecimalFormat format = new DecimalFormat("0.#"); 481 // converted to degrees of upward camera tilt 482 return format.format(-value.shortValue() / 10.0); 483 } 484 485 @Nullable 486 public String getSweepPanoramaDirectionDescription() 487 { 488 return getIndexedDescription(TAG_SWEEP_PANORAMA_DIRECTION, 489 "Off", "Left to Right", "Right to Left", "Top to Bottom", "Bottom to Top"); 490 } 491 492 @Nullable 493 public String getTimerRecordingDescription() 494 { 495 return getIndexedDescription(TAG_TIMER_RECORDING, 496 "Off", "Time Lapse", "Stop-motion Animation"); 497 } 498 499 @Nullable 500 public String getHDRDescription() 501 { 502 Integer value = _directory.getInteger(TAG_HDR); 503 if (value == null) 504 return null; 505 506 switch (value) 507 { 508 case 0: 509 return "Off"; 510 case 100: 511 return "1 EV"; 512 case 200: 513 return "2 EV"; 514 case 300: 515 return "3 EV"; 516 case 32868: 517 return "1 EV (Auto)"; 518 case 32968: 519 return "2 EV (Auto)"; 520 case 33068: 521 return "3 EV (Auto)"; 522 default: 523 return String.format("Unknown (%d)", value); 524 } 525 } 526 527 @Nullable 528 public String getShutterTypeDescription() 529 { 530 return getIndexedDescription(TAG_SHUTTER_TYPE, 531 "Mechanical", "Electronic", "Hybrid"); 532 } 533 534 @Nullable 535 public String getTouchAeDescription() 536 { 537 return getIndexedDescription(TAG_TOUCH_AE, 538 "Off", "On"); 539 } 540 541 @Nullable 311 542 public String getBabyNameDescription() 312 543 { 313 return getAsciiStringFromBytes(TAG_BABY_NAME);544 return trim(getStringFromBytes(TAG_BABY_NAME, Charsets.UTF_8)); 314 545 } 315 546 … … 317 548 public String getLocationDescription() 318 549 { 319 return getAsciiStringFromBytes(TAG_LOCATION);550 return trim(getStringFromBytes(TAG_LOCATION, Charsets.UTF_8)); 320 551 } 321 552
Note:
See TracChangeset
for help on using the changeset viewer.