Changeset 10862 in josm for trunk/src/com/drew/metadata/exif/ExifTiffHandler.java
- Timestamp:
- 2016-08-20T20:58:03+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/ExifTiffHandler.java
r8243 r10862 1 1 /* 2 * Copyright 2002-201 5Drew Noakes2 * Copyright 2002-2016 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 26 26 import com.drew.lang.SequentialByteArrayReader; 27 27 import com.drew.lang.annotations.NotNull; 28 import com.drew.lang.annotations.Nullable; 28 29 import com.drew.metadata.Directory; 29 30 import com.drew.metadata.Metadata; … … 47 48 private final boolean _storeThumbnailBytes; 48 49 49 public ExifTiffHandler(@NotNull Metadata metadata, boolean storeThumbnailBytes) 50 public ExifTiffHandler(@NotNull Metadata metadata, boolean storeThumbnailBytes, @Nullable Directory parentDirectory) 50 51 { 51 52 super(metadata, ExifIFD0Directory.class); 52 53 _storeThumbnailBytes = storeThumbnailBytes; 54 55 if (parentDirectory != null) 56 _currentDirectory.setParent(parentDirectory); 53 57 } 54 58 … … 65 69 } 66 70 67 public boolean isTagIfdPointer(int tagType)68 { 69 if (tag Type== ExifIFD0Directory.TAG_EXIF_SUB_IFD_OFFSET&& _currentDirectory instanceof ExifIFD0Directory) {71 public boolean tryEnterSubIfd(int tagId) 72 { 73 if (tagId == ExifDirectoryBase.TAG_SUB_IFD_OFFSET) { 70 74 pushDirectory(ExifSubIFDDirectory.class); 71 75 return true; 72 } else if (tagType == ExifIFD0Directory.TAG_GPS_INFO_OFFSET && _currentDirectory instanceof ExifIFD0Directory) { 73 pushDirectory(GpsDirectory.class); 74 return true; 75 } else if (tagType == ExifSubIFDDirectory.TAG_INTEROP_OFFSET && _currentDirectory instanceof ExifSubIFDDirectory) { 76 pushDirectory(ExifInteropDirectory.class); 77 return true; 76 } 77 78 if (_currentDirectory instanceof ExifIFD0Directory) { 79 if (tagId == ExifIFD0Directory.TAG_EXIF_SUB_IFD_OFFSET) { 80 pushDirectory(ExifSubIFDDirectory.class); 81 return true; 82 } 83 84 if (tagId == ExifIFD0Directory.TAG_GPS_INFO_OFFSET) { 85 pushDirectory(GpsDirectory.class); 86 return true; 87 } 88 } 89 90 if (_currentDirectory instanceof ExifSubIFDDirectory) { 91 if (tagId == ExifSubIFDDirectory.TAG_INTEROP_OFFSET) { 92 pushDirectory(ExifInteropDirectory.class); 93 return true; 94 } 95 } 96 97 if (_currentDirectory instanceof OlympusMakernoteDirectory) { 98 if (tagId == OlympusMakernoteDirectory.TAG_EQUIPMENT) { 99 pushDirectory(OlympusEquipmentMakernoteDirectory.class); 100 return true; 101 } 102 103 if (tagId == OlympusMakernoteDirectory.TAG_CAMERA_SETTINGS) { 104 pushDirectory(OlympusCameraSettingsMakernoteDirectory.class); 105 return true; 106 } 78 107 } 79 108 … … 96 125 // NOTE have seen the CanonMakernoteDirectory IFD have a follower pointer, but it points to invalid data. 97 126 return false; 127 } 128 129 @Nullable 130 public Long tryCustomProcessFormat(final int tagId, final int formatCode, final long componentCount) 131 { 132 if (formatCode == 13) 133 return componentCount * 4; 134 135 return null; 98 136 } 99 137 … … 115 153 if (reader.getInt8(tagOffset) == 0x1c) { 116 154 final byte[] iptcBytes = reader.getBytes(tagOffset, byteCount); 117 new IptcReader().extract(new SequentialByteArrayReader(iptcBytes), _metadata, iptcBytes.length); 155 new IptcReader().extract(new SequentialByteArrayReader(iptcBytes), _metadata, iptcBytes.length, _currentDirectory); 118 156 return true; 119 157 } … … 129 167 // after the extraction process, if we have the correct tags, we may be able to store thumbnail information 130 168 ExifThumbnailDirectory thumbnailDirectory = _metadata.getFirstDirectoryOfType(ExifThumbnailDirectory.class); 131 if (thumbnailDirectory != null && thumbnailDirectory.containsTag(ExifThumbnailDirectory.TAG_ THUMBNAIL_COMPRESSION)) {169 if (thumbnailDirectory != null && thumbnailDirectory.containsTag(ExifThumbnailDirectory.TAG_COMPRESSION)) { 132 170 Integer offset = thumbnailDirectory.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_OFFSET); 133 171 Integer length = thumbnailDirectory.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_LENGTH); … … 164 202 final String firstSevenChars = reader.getString(makernoteOffset, 7); 165 203 final String firstEightChars = reader.getString(makernoteOffset, 8); 204 final String firstTenChars = reader.getString(makernoteOffset, 10); 166 205 final String firstTwelveChars = reader.getString(makernoteOffset, 12); 167 206 168 207 boolean byteOrderBefore = reader.isMotorolaByteOrder(); 169 208 170 if ("OLYMP".equals(first FiveChars) || "EPSON".equals(firstFiveChars) || "AGFA".equals(firstFourChars)) {209 if ("OLYMP\0".equals(firstSixChars) || "EPSON".equals(firstFiveChars) || "AGFA".equals(firstFourChars)) { 171 210 // Olympus Makernote 172 211 // Epson and Agfa use Olympus makernote standard: http://www.ozhiker.com/electronics/pjmt/jpeg_info/ 173 212 pushDirectory(OlympusMakernoteDirectory.class); 174 213 TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset); 214 } else if ("OLYMPUS\0II".equals(firstTenChars)) { 215 // Olympus Makernote (alternate) 216 // Note that data is relative to the beginning of the makernote 217 // http://exiv2.org/makernote.html 218 pushDirectory(OlympusMakernoteDirectory.class); 219 TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 12, makernoteOffset); 175 220 } else if (cameraMake != null && cameraMake.toUpperCase().startsWith("MINOLTA")) { 176 221 // Cases seen with the model starting with MINOLTA in capitals seem to have a valid Olympus makernote
Note:
See TracChangeset
for help on using the changeset viewer.
