| 1 | /*
|
|---|
| 2 | * Copyright 2002-2019 Drew Noakes and contributors
|
|---|
| 3 | *
|
|---|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
|---|
| 5 | * you may not use this file except in compliance with the License.
|
|---|
| 6 | * You may obtain a copy of the License at
|
|---|
| 7 | *
|
|---|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
|---|
| 9 | *
|
|---|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
|---|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
|---|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|---|
| 13 | * See the License for the specific language governing permissions and
|
|---|
| 14 | * limitations under the License.
|
|---|
| 15 | *
|
|---|
| 16 | * More information about this project is available at:
|
|---|
| 17 | *
|
|---|
| 18 | * https://drewnoakes.com/code/exif/
|
|---|
| 19 | * https://github.com/drewnoakes/metadata-extractor
|
|---|
| 20 | */
|
|---|
| 21 | package com.drew.metadata.exif;
|
|---|
| 22 |
|
|---|
| 23 | import java.io.ByteArrayInputStream;
|
|---|
| 24 | import java.io.IOException;
|
|---|
| 25 | import java.util.Arrays;
|
|---|
| 26 | import java.util.Set;
|
|---|
| 27 |
|
|---|
| 28 | import com.drew.imaging.jpeg.JpegMetadataReader;
|
|---|
| 29 | import com.drew.imaging.jpeg.JpegProcessingException;
|
|---|
| 30 | import com.drew.imaging.tiff.TiffProcessingException;
|
|---|
| 31 | import com.drew.imaging.tiff.TiffReader;
|
|---|
| 32 | import com.drew.lang.BufferBoundsException;
|
|---|
| 33 | import com.drew.lang.Charsets;
|
|---|
| 34 | import com.drew.lang.RandomAccessReader;
|
|---|
| 35 | import com.drew.lang.SequentialByteArrayReader;
|
|---|
| 36 | import com.drew.lang.annotations.NotNull;
|
|---|
| 37 | import com.drew.lang.annotations.Nullable;
|
|---|
| 38 | import com.drew.metadata.Directory;
|
|---|
| 39 | import com.drew.metadata.Metadata;
|
|---|
| 40 | import com.drew.metadata.StringValue;
|
|---|
| 41 | import com.drew.metadata.exif.makernotes.AppleMakernoteDirectory;
|
|---|
| 42 | import com.drew.metadata.exif.makernotes.CanonMakernoteDirectory;
|
|---|
| 43 | import com.drew.metadata.exif.makernotes.CasioType1MakernoteDirectory;
|
|---|
| 44 | import com.drew.metadata.exif.makernotes.CasioType2MakernoteDirectory;
|
|---|
| 45 | import com.drew.metadata.exif.makernotes.FujifilmMakernoteDirectory;
|
|---|
| 46 | import com.drew.metadata.exif.makernotes.KodakMakernoteDirectory;
|
|---|
| 47 | import com.drew.metadata.exif.makernotes.KyoceraMakernoteDirectory;
|
|---|
| 48 | import com.drew.metadata.exif.makernotes.LeicaMakernoteDirectory;
|
|---|
| 49 | import com.drew.metadata.exif.makernotes.LeicaType5MakernoteDirectory;
|
|---|
| 50 | import com.drew.metadata.exif.makernotes.NikonType1MakernoteDirectory;
|
|---|
| 51 | import com.drew.metadata.exif.makernotes.NikonType2MakernoteDirectory;
|
|---|
| 52 | import com.drew.metadata.exif.makernotes.OlympusCameraSettingsMakernoteDirectory;
|
|---|
| 53 | import com.drew.metadata.exif.makernotes.OlympusEquipmentMakernoteDirectory;
|
|---|
| 54 | import com.drew.metadata.exif.makernotes.OlympusFocusInfoMakernoteDirectory;
|
|---|
| 55 | import com.drew.metadata.exif.makernotes.OlympusImageProcessingMakernoteDirectory;
|
|---|
| 56 | import com.drew.metadata.exif.makernotes.OlympusMakernoteDirectory;
|
|---|
| 57 | import com.drew.metadata.exif.makernotes.OlympusRawDevelopment2MakernoteDirectory;
|
|---|
| 58 | import com.drew.metadata.exif.makernotes.OlympusRawDevelopmentMakernoteDirectory;
|
|---|
| 59 | import com.drew.metadata.exif.makernotes.OlympusRawInfoMakernoteDirectory;
|
|---|
| 60 | import com.drew.metadata.exif.makernotes.PanasonicMakernoteDirectory;
|
|---|
| 61 | import com.drew.metadata.exif.makernotes.PentaxMakernoteDirectory;
|
|---|
| 62 | import com.drew.metadata.exif.makernotes.ReconyxHyperFireMakernoteDirectory;
|
|---|
| 63 | import com.drew.metadata.exif.makernotes.ReconyxUltraFireMakernoteDirectory;
|
|---|
| 64 | import com.drew.metadata.exif.makernotes.RicohMakernoteDirectory;
|
|---|
| 65 | import com.drew.metadata.exif.makernotes.SamsungType2MakernoteDirectory;
|
|---|
| 66 | import com.drew.metadata.exif.makernotes.SanyoMakernoteDirectory;
|
|---|
| 67 | import com.drew.metadata.exif.makernotes.SigmaMakernoteDirectory;
|
|---|
| 68 | import com.drew.metadata.exif.makernotes.SonyType1MakernoteDirectory;
|
|---|
| 69 | import com.drew.metadata.exif.makernotes.SonyType6MakernoteDirectory;
|
|---|
| 70 | import com.drew.metadata.iptc.IptcReader;
|
|---|
| 71 | import com.drew.metadata.tiff.DirectoryTiffHandler;
|
|---|
| 72 |
|
|---|
| 73 | /**
|
|---|
| 74 | * Implementation of {@link com.drew.imaging.tiff.TiffHandler} used for handling TIFF tags according to the Exif
|
|---|
| 75 | * standard.
|
|---|
| 76 | * <p>
|
|---|
| 77 | * Includes support for camera manufacturer makernotes.
|
|---|
| 78 | *
|
|---|
| 79 | * @author Drew Noakes https://drewnoakes.com
|
|---|
| 80 | */
|
|---|
| 81 | public class ExifTiffHandler extends DirectoryTiffHandler
|
|---|
| 82 | {
|
|---|
| 83 | public ExifTiffHandler(@NotNull Metadata metadata, @Nullable Directory parentDirectory)
|
|---|
| 84 | {
|
|---|
| 85 | super(metadata, parentDirectory);
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | public void setTiffMarker(int marker) throws TiffProcessingException
|
|---|
| 89 | {
|
|---|
| 90 | final int standardTiffMarker = 0x002A;
|
|---|
| 91 | final int olympusRawTiffMarker = 0x4F52; // for ORF files
|
|---|
| 92 | final int olympusRawTiffMarker2 = 0x5352; // for ORF files
|
|---|
| 93 | final int panasonicRawTiffMarker = 0x0055; // for RW2 files
|
|---|
| 94 |
|
|---|
| 95 | switch (marker) {
|
|---|
| 96 | case standardTiffMarker:
|
|---|
| 97 | case olympusRawTiffMarker: // TODO implement an IFD0, if there is one
|
|---|
| 98 | case olympusRawTiffMarker2: // TODO implement an IFD0, if there is one
|
|---|
| 99 | pushDirectory(ExifIFD0Directory.class);
|
|---|
| 100 | break;
|
|---|
| 101 | case panasonicRawTiffMarker:
|
|---|
| 102 | pushDirectory(PanasonicRawIFD0Directory.class);
|
|---|
| 103 | break;
|
|---|
| 104 | default:
|
|---|
| 105 | throw new TiffProcessingException(String.format("Unexpected TIFF marker: 0x%X", marker));
|
|---|
| 106 | }
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | public boolean tryEnterSubIfd(int tagId)
|
|---|
| 110 | {
|
|---|
| 111 | if (tagId == ExifDirectoryBase.TAG_SUB_IFD_OFFSET) {
|
|---|
| 112 | pushDirectory(ExifSubIFDDirectory.class);
|
|---|
| 113 | return true;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | if (_currentDirectory instanceof ExifIFD0Directory || _currentDirectory instanceof PanasonicRawIFD0Directory) {
|
|---|
| 117 | if (tagId == ExifIFD0Directory.TAG_EXIF_SUB_IFD_OFFSET) {
|
|---|
| 118 | pushDirectory(ExifSubIFDDirectory.class);
|
|---|
| 119 | return true;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | if (tagId == ExifIFD0Directory.TAG_GPS_INFO_OFFSET) {
|
|---|
| 123 | pushDirectory(GpsDirectory.class);
|
|---|
| 124 | return true;
|
|---|
| 125 | }
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | if (_currentDirectory instanceof ExifSubIFDDirectory) {
|
|---|
| 129 | if (tagId == ExifSubIFDDirectory.TAG_INTEROP_OFFSET) {
|
|---|
| 130 | pushDirectory(ExifInteropDirectory.class);
|
|---|
| 131 | return true;
|
|---|
| 132 | }
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | if (_currentDirectory instanceof OlympusMakernoteDirectory) {
|
|---|
| 136 | // Note: these also appear in customProcessTag because some are IFD pointers while others begin immediately
|
|---|
| 137 | // for the same directories
|
|---|
| 138 | switch(tagId) {
|
|---|
| 139 | case OlympusMakernoteDirectory.TAG_EQUIPMENT:
|
|---|
| 140 | pushDirectory(OlympusEquipmentMakernoteDirectory.class);
|
|---|
| 141 | return true;
|
|---|
| 142 | case OlympusMakernoteDirectory.TAG_CAMERA_SETTINGS:
|
|---|
| 143 | pushDirectory(OlympusCameraSettingsMakernoteDirectory.class);
|
|---|
| 144 | return true;
|
|---|
| 145 | case OlympusMakernoteDirectory.TAG_RAW_DEVELOPMENT:
|
|---|
| 146 | pushDirectory(OlympusRawDevelopmentMakernoteDirectory.class);
|
|---|
| 147 | return true;
|
|---|
| 148 | case OlympusMakernoteDirectory.TAG_RAW_DEVELOPMENT_2:
|
|---|
| 149 | pushDirectory(OlympusRawDevelopment2MakernoteDirectory.class);
|
|---|
| 150 | return true;
|
|---|
| 151 | case OlympusMakernoteDirectory.TAG_IMAGE_PROCESSING:
|
|---|
| 152 | pushDirectory(OlympusImageProcessingMakernoteDirectory.class);
|
|---|
| 153 | return true;
|
|---|
| 154 | case OlympusMakernoteDirectory.TAG_FOCUS_INFO:
|
|---|
| 155 | pushDirectory(OlympusFocusInfoMakernoteDirectory.class);
|
|---|
| 156 | return true;
|
|---|
| 157 | case OlympusMakernoteDirectory.TAG_RAW_INFO:
|
|---|
| 158 | pushDirectory(OlympusRawInfoMakernoteDirectory.class);
|
|---|
| 159 | return true;
|
|---|
| 160 | case OlympusMakernoteDirectory.TAG_MAIN_INFO:
|
|---|
| 161 | pushDirectory(OlympusMakernoteDirectory.class);
|
|---|
| 162 | return true;
|
|---|
| 163 | }
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | return false;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | public boolean hasFollowerIfd()
|
|---|
| 170 | {
|
|---|
| 171 | // In Exif, the only known 'follower' IFD is the thumbnail one, however this may not be the case.
|
|---|
| 172 | // UPDATE: In multipage TIFFs, the 'follower' IFD points to the next image in the set
|
|---|
| 173 | if (_currentDirectory instanceof ExifIFD0Directory || _currentDirectory instanceof ExifImageDirectory) {
|
|---|
| 174 | // If the PageNumber tag is defined, assume this is a multipage TIFF or similar
|
|---|
| 175 | // TODO: Find better ways to know which follower Directory should be used
|
|---|
| 176 | if (_currentDirectory.containsTag(ExifDirectoryBase.TAG_PAGE_NUMBER))
|
|---|
| 177 | pushDirectory(ExifImageDirectory.class);
|
|---|
| 178 | else
|
|---|
| 179 | pushDirectory(ExifThumbnailDirectory.class);
|
|---|
| 180 | return true;
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | // The Canon EOS 7D (CR2) has three chained/following thumbnail IFDs
|
|---|
| 184 | if (_currentDirectory instanceof ExifThumbnailDirectory)
|
|---|
| 185 | return true;
|
|---|
| 186 |
|
|---|
| 187 | // This should not happen, as Exif doesn't use follower IFDs apart from that above.
|
|---|
| 188 | // NOTE have seen the CanonMakernoteDirectory IFD have a follower pointer, but it points to invalid data.
|
|---|
| 189 | return false;
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | @Nullable
|
|---|
| 193 | public Long tryCustomProcessFormat(final int tagId, final int formatCode, final long componentCount)
|
|---|
| 194 | {
|
|---|
| 195 | if (formatCode == 13)
|
|---|
| 196 | return componentCount * 4;
|
|---|
| 197 |
|
|---|
| 198 | // an unknown (0) formatCode needs to be potentially handled later as a highly custom directory tag
|
|---|
| 199 | if (formatCode == 0)
|
|---|
| 200 | return 0L;
|
|---|
| 201 |
|
|---|
| 202 | return null;
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | public boolean customProcessTag(final int tagOffset,
|
|---|
| 206 | final @NotNull Set<Integer> processedIfdOffsets,
|
|---|
| 207 | final int tiffHeaderOffset,
|
|---|
| 208 | final @NotNull RandomAccessReader reader,
|
|---|
| 209 | final int tagId,
|
|---|
| 210 | final int byteCount) throws IOException
|
|---|
| 211 | {
|
|---|
| 212 | assert(_currentDirectory != null);
|
|---|
| 213 |
|
|---|
| 214 | // Some 0x0000 tags have a 0 byteCount. Determine whether it's bad.
|
|---|
| 215 | if (tagId == 0) {
|
|---|
| 216 | if (_currentDirectory.containsTag(tagId)) {
|
|---|
| 217 | // Let it go through for now. Some directories handle it, some don't
|
|---|
| 218 | return false;
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | // Skip over 0x0000 tags that don't have any associated bytes. No idea what it contains in this case, if anything.
|
|---|
| 222 | if (byteCount == 0)
|
|---|
| 223 | return true;
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | // Custom processing for the Makernote tag
|
|---|
| 227 | if (tagId == ExifSubIFDDirectory.TAG_MAKERNOTE && _currentDirectory instanceof ExifSubIFDDirectory) {
|
|---|
| 228 | return processMakernote(tagOffset, processedIfdOffsets, tiffHeaderOffset, reader);
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | // Custom processing for embedded IPTC data
|
|---|
| 232 | if (tagId == ExifSubIFDDirectory.TAG_IPTC_NAA && _currentDirectory instanceof ExifIFD0Directory) {
|
|---|
| 233 | // NOTE Adobe sets type 4 for IPTC instead of 7
|
|---|
| 234 | if (reader.getInt8(tagOffset) == 0x1c) {
|
|---|
| 235 | final byte[] iptcBytes = reader.getBytes(tagOffset, byteCount);
|
|---|
| 236 | new IptcReader().extract(new SequentialByteArrayReader(iptcBytes), _metadata, iptcBytes.length, _currentDirectory);
|
|---|
| 237 | return true;
|
|---|
| 238 | }
|
|---|
| 239 | return false;
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | if (handlePrintIM(_currentDirectory, tagId))
|
|---|
| 243 | {
|
|---|
| 244 | PrintIMDirectory printIMDirectory = new PrintIMDirectory();
|
|---|
| 245 | printIMDirectory.setParent(_currentDirectory);
|
|---|
| 246 | _metadata.addDirectory(printIMDirectory);
|
|---|
| 247 | processPrintIM(printIMDirectory, tagOffset, reader, byteCount);
|
|---|
| 248 | return true;
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | // Note: these also appear in tryEnterSubIfd because some are IFD pointers while others begin immediately
|
|---|
| 252 | // for the same directories
|
|---|
| 253 | if (_currentDirectory instanceof OlympusMakernoteDirectory) {
|
|---|
| 254 | switch (tagId) {
|
|---|
| 255 | case OlympusMakernoteDirectory.TAG_EQUIPMENT:
|
|---|
| 256 | pushDirectory(OlympusEquipmentMakernoteDirectory.class);
|
|---|
| 257 | TiffReader.processIfd(this, reader, processedIfdOffsets, tagOffset, tiffHeaderOffset);
|
|---|
| 258 | return true;
|
|---|
| 259 | case OlympusMakernoteDirectory.TAG_CAMERA_SETTINGS:
|
|---|
| 260 | pushDirectory(OlympusCameraSettingsMakernoteDirectory.class);
|
|---|
| 261 | TiffReader.processIfd(this, reader, processedIfdOffsets, tagOffset, tiffHeaderOffset);
|
|---|
| 262 | return true;
|
|---|
| 263 | case OlympusMakernoteDirectory.TAG_RAW_DEVELOPMENT:
|
|---|
| 264 | pushDirectory(OlympusRawDevelopmentMakernoteDirectory.class);
|
|---|
| 265 | TiffReader.processIfd(this, reader, processedIfdOffsets, tagOffset, tiffHeaderOffset);
|
|---|
| 266 | return true;
|
|---|
| 267 | case OlympusMakernoteDirectory.TAG_RAW_DEVELOPMENT_2:
|
|---|
| 268 | pushDirectory(OlympusRawDevelopment2MakernoteDirectory.class);
|
|---|
| 269 | TiffReader.processIfd(this, reader, processedIfdOffsets, tagOffset, tiffHeaderOffset);
|
|---|
| 270 | return true;
|
|---|
| 271 | case OlympusMakernoteDirectory.TAG_IMAGE_PROCESSING:
|
|---|
| 272 | pushDirectory(OlympusImageProcessingMakernoteDirectory.class);
|
|---|
| 273 | TiffReader.processIfd(this, reader, processedIfdOffsets, tagOffset, tiffHeaderOffset);
|
|---|
| 274 | return true;
|
|---|
| 275 | case OlympusMakernoteDirectory.TAG_FOCUS_INFO:
|
|---|
| 276 | pushDirectory(OlympusFocusInfoMakernoteDirectory.class);
|
|---|
| 277 | TiffReader.processIfd(this, reader, processedIfdOffsets, tagOffset, tiffHeaderOffset);
|
|---|
| 278 | return true;
|
|---|
| 279 | case OlympusMakernoteDirectory.TAG_RAW_INFO:
|
|---|
| 280 | pushDirectory(OlympusRawInfoMakernoteDirectory.class);
|
|---|
| 281 | TiffReader.processIfd(this, reader, processedIfdOffsets, tagOffset, tiffHeaderOffset);
|
|---|
| 282 | return true;
|
|---|
| 283 | case OlympusMakernoteDirectory.TAG_MAIN_INFO:
|
|---|
| 284 | pushDirectory(OlympusMakernoteDirectory.class);
|
|---|
| 285 | TiffReader.processIfd(this, reader, processedIfdOffsets, tagOffset, tiffHeaderOffset);
|
|---|
| 286 | return true;
|
|---|
| 287 | }
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | if (_currentDirectory instanceof PanasonicRawIFD0Directory) {
|
|---|
| 291 | // these contain binary data with specific offsets, and can't be processed as regular ifd's.
|
|---|
| 292 | // The binary data is broken into 'fake' tags and there is a pattern.
|
|---|
| 293 | switch (tagId) {
|
|---|
| 294 | case PanasonicRawIFD0Directory.TagWbInfo:
|
|---|
| 295 | PanasonicRawWbInfoDirectory dirWbInfo = new PanasonicRawWbInfoDirectory();
|
|---|
| 296 | dirWbInfo.setParent(_currentDirectory);
|
|---|
| 297 | _metadata.addDirectory(dirWbInfo);
|
|---|
| 298 | processBinary(dirWbInfo, tagOffset, reader, byteCount, false, 2);
|
|---|
| 299 | return true;
|
|---|
| 300 | case PanasonicRawIFD0Directory.TagWbInfo2:
|
|---|
| 301 | PanasonicRawWbInfo2Directory dirWbInfo2 = new PanasonicRawWbInfo2Directory();
|
|---|
| 302 | dirWbInfo2.setParent(_currentDirectory);
|
|---|
| 303 | _metadata.addDirectory(dirWbInfo2);
|
|---|
| 304 | processBinary(dirWbInfo2, tagOffset, reader, byteCount, false, 3);
|
|---|
| 305 | return true;
|
|---|
| 306 | case PanasonicRawIFD0Directory.TagDistortionInfo:
|
|---|
| 307 | PanasonicRawDistortionDirectory dirDistort = new PanasonicRawDistortionDirectory();
|
|---|
| 308 | dirDistort.setParent(_currentDirectory);
|
|---|
| 309 | _metadata.addDirectory(dirDistort);
|
|---|
| 310 | processBinary(dirDistort, tagOffset, reader, byteCount, true, 1);
|
|---|
| 311 | return true;
|
|---|
| 312 | }
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 | // Panasonic RAW sometimes contains an embedded version of the data as a JPG file.
|
|---|
| 316 | if (tagId == PanasonicRawIFD0Directory.TagJpgFromRaw && _currentDirectory instanceof PanasonicRawIFD0Directory) {
|
|---|
| 317 | byte[] jpegrawbytes = reader.getBytes(tagOffset, byteCount);
|
|---|
| 318 |
|
|---|
| 319 | // Extract information from embedded image since it is metadata-rich
|
|---|
| 320 | ByteArrayInputStream jpegmem = new ByteArrayInputStream(jpegrawbytes);
|
|---|
| 321 | try {
|
|---|
| 322 | Metadata jpegDirectory = JpegMetadataReader.readMetadata(jpegmem);
|
|---|
| 323 | for (Directory directory : jpegDirectory.getDirectories()) {
|
|---|
| 324 | directory.setParent(_currentDirectory);
|
|---|
| 325 | _metadata.addDirectory(directory);
|
|---|
| 326 | }
|
|---|
| 327 | return true;
|
|---|
| 328 | } catch (JpegProcessingException e) {
|
|---|
| 329 | _currentDirectory.addError("Error processing JpgFromRaw: " + e.getMessage());
|
|---|
| 330 | } catch (IOException e) {
|
|---|
| 331 | _currentDirectory.addError("Error reading JpgFromRaw: " + e.getMessage());
|
|---|
| 332 | }
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | return false;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | private static void processBinary(@NotNull final Directory directory, final int tagValueOffset, @NotNull final RandomAccessReader reader, final int byteCount, final Boolean isSigned, final int arrayLength) throws IOException
|
|---|
| 339 | {
|
|---|
| 340 | // expects signed/unsigned int16 (for now)
|
|---|
| 341 | //int byteSize = isSigned ? sizeof(short) : sizeof(ushort);
|
|---|
| 342 | int byteSize = 2;
|
|---|
| 343 |
|
|---|
| 344 | // 'directory' is assumed to contain tags that correspond to the byte position unless it's a set of bytes
|
|---|
| 345 | for (int i = 0; i < byteCount; i++) {
|
|---|
| 346 | if (directory.hasTagName(i)) {
|
|---|
| 347 | // only process this tag if the 'next' integral tag exists. Otherwise, it's a set of bytes
|
|---|
| 348 | if (i < byteCount - 1 && directory.hasTagName(i + 1)) {
|
|---|
| 349 | if (isSigned)
|
|---|
| 350 | directory.setObject(i, reader.getInt16(tagValueOffset + (i* byteSize)));
|
|---|
| 351 | else
|
|---|
| 352 | directory.setObject(i, reader.getUInt16(tagValueOffset + (i* byteSize)));
|
|---|
| 353 | } else {
|
|---|
| 354 | // the next arrayLength bytes are a multi-byte value
|
|---|
| 355 | if (isSigned) {
|
|---|
| 356 | short[] val = new short[arrayLength];
|
|---|
| 357 | for (int j = 0; j<val.length; j++)
|
|---|
| 358 | val[j] = reader.getInt16(tagValueOffset + ((i + j) * byteSize));
|
|---|
| 359 | directory.setObjectArray(i, val);
|
|---|
| 360 | } else {
|
|---|
| 361 | int[] val = new int[arrayLength];
|
|---|
| 362 | for (int j = 0; j<val.length; j++)
|
|---|
| 363 | val[j] = reader.getUInt16(tagValueOffset + ((i + j) * byteSize));
|
|---|
| 364 | directory.setObjectArray(i, val);
|
|---|
| 365 | }
|
|---|
| 366 |
|
|---|
| 367 | i += arrayLength - 1;
|
|---|
| 368 | }
|
|---|
| 369 | }
|
|---|
| 370 | }
|
|---|
| 371 | }
|
|---|
| 372 |
|
|---|
| 373 | /** Read a given number of bytes from the stream
|
|---|
| 374 | *
|
|---|
| 375 | * This method is employed to "suppress" attempts to read beyond end of the
|
|---|
| 376 | * file as may happen at the beginning of processMakernote when we read
|
|---|
| 377 | * increasingly longer camera makes.
|
|---|
| 378 | *
|
|---|
| 379 | * Instead of failing altogether in this context we return an empty string
|
|---|
| 380 | * which will fail all sensible attempts to compare to makes while avoiding
|
|---|
| 381 | * a full-on failure.
|
|---|
| 382 | */
|
|---|
| 383 | @NotNull
|
|---|
| 384 | private static String getReaderString(final @NotNull RandomAccessReader reader, final int makernoteOffset, final int bytesRequested) throws IOException
|
|---|
| 385 | {
|
|---|
| 386 | try {
|
|---|
| 387 | return reader.getString(makernoteOffset, bytesRequested, Charsets.UTF_8);
|
|---|
| 388 | } catch(BufferBoundsException e) {
|
|---|
| 389 | return "";
|
|---|
| 390 | }
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | private boolean processMakernote(final int makernoteOffset,
|
|---|
| 394 | final @NotNull Set<Integer> processedIfdOffsets,
|
|---|
| 395 | final int tiffHeaderOffset,
|
|---|
| 396 | final @NotNull RandomAccessReader reader) throws IOException
|
|---|
| 397 | {
|
|---|
| 398 | assert(_currentDirectory != null);
|
|---|
| 399 |
|
|---|
| 400 | // Determine the camera model and makernote format.
|
|---|
| 401 | Directory ifd0Directory = _metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
|
|---|
| 402 |
|
|---|
| 403 | String cameraMake = ifd0Directory == null ? null : ifd0Directory.getString(ExifIFD0Directory.TAG_MAKE);
|
|---|
| 404 |
|
|---|
| 405 | final String firstTwoChars = getReaderString(reader, makernoteOffset, 2);
|
|---|
| 406 | final String firstThreeChars = getReaderString(reader, makernoteOffset, 3);
|
|---|
| 407 | final String firstFourChars = getReaderString(reader, makernoteOffset, 4);
|
|---|
| 408 | final String firstFiveChars = getReaderString(reader, makernoteOffset, 5);
|
|---|
| 409 | final String firstSixChars = getReaderString(reader, makernoteOffset, 6);
|
|---|
| 410 | final String firstSevenChars = getReaderString(reader, makernoteOffset, 7);
|
|---|
| 411 | final String firstEightChars = getReaderString(reader, makernoteOffset, 8);
|
|---|
| 412 | final String firstNineChars = getReaderString(reader, makernoteOffset, 9);
|
|---|
| 413 | final String firstTenChars = getReaderString(reader, makernoteOffset, 10);
|
|---|
| 414 | final String firstTwelveChars = getReaderString(reader, makernoteOffset, 12);
|
|---|
| 415 |
|
|---|
| 416 | boolean byteOrderBefore = reader.isMotorolaByteOrder();
|
|---|
| 417 |
|
|---|
| 418 | if ("OLYMP\0".equals(firstSixChars) || "EPSON".equals(firstFiveChars) || "AGFA".equals(firstFourChars)) {
|
|---|
| 419 | // Olympus Makernote
|
|---|
| 420 | // Epson and Agfa use Olympus makernote standard: http://www.ozhiker.com/electronics/pjmt/jpeg_info/
|
|---|
| 421 | pushDirectory(OlympusMakernoteDirectory.class);
|
|---|
| 422 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
|
|---|
| 423 | } else if ("OLYMPUS\0II".equals(firstTenChars)) {
|
|---|
| 424 | // Olympus Makernote (alternate)
|
|---|
| 425 | // Note that data is relative to the beginning of the makernote
|
|---|
| 426 | // http://exiv2.org/makernote.html
|
|---|
| 427 | pushDirectory(OlympusMakernoteDirectory.class);
|
|---|
| 428 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 12, makernoteOffset);
|
|---|
| 429 | } else if (cameraMake != null && cameraMake.toUpperCase().startsWith("MINOLTA")) {
|
|---|
| 430 | // Cases seen with the model starting with MINOLTA in capitals seem to have a valid Olympus makernote
|
|---|
| 431 | // area that commences immediately.
|
|---|
| 432 | pushDirectory(OlympusMakernoteDirectory.class);
|
|---|
| 433 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
|
|---|
| 434 | } else if (cameraMake != null && cameraMake.trim().toUpperCase().startsWith("NIKON")) {
|
|---|
| 435 | if ("Nikon".equals(firstFiveChars)) {
|
|---|
| 436 | /* There are two scenarios here:
|
|---|
| 437 | * Type 1: **
|
|---|
| 438 | * :0000: 4E 69 6B 6F 6E 00 01 00-05 00 02 00 02 00 06 00 Nikon...........
|
|---|
| 439 | * :0010: 00 00 EC 02 00 00 03 00-03 00 01 00 00 00 06 00 ................
|
|---|
| 440 | * Type 3: **
|
|---|
| 441 | * :0000: 4E 69 6B 6F 6E 00 02 00-00 00 4D 4D 00 2A 00 00 Nikon....MM.*...
|
|---|
| 442 | * :0010: 00 08 00 1E 00 01 00 07-00 00 00 04 30 32 30 30 ............0200
|
|---|
| 443 | */
|
|---|
| 444 | switch (reader.getUInt8(makernoteOffset + 6)) {
|
|---|
| 445 | case 1:
|
|---|
| 446 | pushDirectory(NikonType1MakernoteDirectory.class);
|
|---|
| 447 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
|
|---|
| 448 | break;
|
|---|
| 449 | case 2:
|
|---|
| 450 | pushDirectory(NikonType2MakernoteDirectory.class);
|
|---|
| 451 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 18, makernoteOffset + 10);
|
|---|
| 452 | break;
|
|---|
| 453 | default:
|
|---|
| 454 | _currentDirectory.addError("Unsupported Nikon makernote data ignored.");
|
|---|
| 455 | break;
|
|---|
| 456 | }
|
|---|
| 457 | } else {
|
|---|
| 458 | // The IFD begins with the first Makernote byte (no ASCII name). This occurs with CoolPix 775, E990 and D1 models.
|
|---|
| 459 | pushDirectory(NikonType2MakernoteDirectory.class);
|
|---|
| 460 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
|
|---|
| 461 | }
|
|---|
| 462 | } else if ("SONY CAM".equals(firstEightChars) || "SONY DSC".equals(firstEightChars)) {
|
|---|
| 463 | pushDirectory(SonyType1MakernoteDirectory.class);
|
|---|
| 464 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 12, tiffHeaderOffset);
|
|---|
| 465 | // Do this check LAST after most other Sony checks
|
|---|
| 466 | } else if (cameraMake != null && cameraMake.startsWith("SONY") &&
|
|---|
| 467 | !Arrays.equals(reader.getBytes(makernoteOffset, 2), new byte[]{ 0x01, 0x00 }) ) {
|
|---|
| 468 | // The IFD begins with the first Makernote byte (no ASCII name). Used in SR2 and ARW images
|
|---|
| 469 | pushDirectory(SonyType1MakernoteDirectory.class);
|
|---|
| 470 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
|
|---|
| 471 | } else if ("SEMC MS\u0000\u0000\u0000\u0000\u0000".equals(firstTwelveChars)) {
|
|---|
| 472 | // force MM for this directory
|
|---|
| 473 | reader.setMotorolaByteOrder(true);
|
|---|
| 474 | // skip 12 byte header + 2 for "MM" + 6
|
|---|
| 475 | pushDirectory(SonyType6MakernoteDirectory.class);
|
|---|
| 476 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 20, tiffHeaderOffset);
|
|---|
| 477 | } else if ("SIGMA\u0000\u0000\u0000".equals(firstEightChars) || "FOVEON\u0000\u0000".equals(firstEightChars)) {
|
|---|
| 478 | pushDirectory(SigmaMakernoteDirectory.class);
|
|---|
| 479 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 10, tiffHeaderOffset);
|
|---|
| 480 | } else if ("KDK".equals(firstThreeChars)) {
|
|---|
| 481 | reader.setMotorolaByteOrder(firstSevenChars.equals("KDK INFO"));
|
|---|
| 482 | KodakMakernoteDirectory directory = new KodakMakernoteDirectory();
|
|---|
| 483 | _metadata.addDirectory(directory);
|
|---|
| 484 | processKodakMakernote(directory, makernoteOffset, reader);
|
|---|
| 485 | } else if ("Canon".equalsIgnoreCase(cameraMake)) {
|
|---|
| 486 | pushDirectory(CanonMakernoteDirectory.class);
|
|---|
| 487 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
|
|---|
| 488 | } else if (cameraMake != null && cameraMake.toUpperCase().startsWith("CASIO")) {
|
|---|
| 489 | if ("QVC\u0000\u0000\u0000".equals(firstSixChars)) {
|
|---|
| 490 | pushDirectory(CasioType2MakernoteDirectory.class);
|
|---|
| 491 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 6, tiffHeaderOffset);
|
|---|
| 492 | } else {
|
|---|
| 493 | pushDirectory(CasioType1MakernoteDirectory.class);
|
|---|
| 494 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
|
|---|
| 495 | }
|
|---|
| 496 | } else if ("FUJIFILM".equals(firstEightChars) || "Fujifilm".equalsIgnoreCase(cameraMake)) {
|
|---|
| 497 | // Note that this also applies to certain Leica cameras, such as the Digilux-4.3
|
|---|
| 498 | reader.setMotorolaByteOrder(false);
|
|---|
| 499 | // the 4 bytes after "FUJIFILM" in the makernote point to the start of the makernote
|
|---|
| 500 | // IFD, though the offset is relative to the start of the makernote, not the TIFF
|
|---|
| 501 | // header (like everywhere else)
|
|---|
| 502 | int ifdStart = makernoteOffset + reader.getInt32(makernoteOffset + 8);
|
|---|
| 503 | pushDirectory(FujifilmMakernoteDirectory.class);
|
|---|
| 504 | TiffReader.processIfd(this, reader, processedIfdOffsets, ifdStart, makernoteOffset);
|
|---|
| 505 | } else if ("KYOCERA".equals(firstSevenChars)) {
|
|---|
| 506 | // http://www.ozhiker.com/electronics/pjmt/jpeg_info/kyocera_mn.html
|
|---|
| 507 | pushDirectory(KyoceraMakernoteDirectory.class);
|
|---|
| 508 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 22, tiffHeaderOffset);
|
|---|
| 509 | } else if ("LEICA".equals(firstFiveChars)) {
|
|---|
| 510 | reader.setMotorolaByteOrder(false);
|
|---|
| 511 |
|
|---|
| 512 | // used by the X1/X2/X VARIO/T
|
|---|
| 513 | // (X1 starts with "LEICA\0\x01\0", Make is "LEICA CAMERA AG")
|
|---|
| 514 | // (X2 starts with "LEICA\0\x05\0", Make is "LEICA CAMERA AG")
|
|---|
| 515 | // (X VARIO starts with "LEICA\0\x04\0", Make is "LEICA CAMERA AG")
|
|---|
| 516 | // (T (Typ 701) starts with "LEICA\0\0x6", Make is "LEICA CAMERA AG")
|
|---|
| 517 | // (X (Typ 113) starts with "LEICA\0\0x7", Make is "LEICA CAMERA AG")
|
|---|
| 518 |
|
|---|
| 519 | if ("LEICA\0\u0001\0".equals(firstEightChars) ||
|
|---|
| 520 | "LEICA\0\u0004\0".equals(firstEightChars) ||
|
|---|
| 521 | "LEICA\0\u0005\0".equals(firstEightChars) ||
|
|---|
| 522 | "LEICA\0\u0006\0".equals(firstEightChars) ||
|
|---|
| 523 | "LEICA\0\u0007\0".equals(firstEightChars))
|
|---|
| 524 | {
|
|---|
| 525 | pushDirectory(LeicaType5MakernoteDirectory.class);
|
|---|
| 526 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, makernoteOffset);
|
|---|
| 527 | } else if ("Leica Camera AG".equals(cameraMake)) {
|
|---|
| 528 | pushDirectory(LeicaMakernoteDirectory.class);
|
|---|
| 529 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
|
|---|
| 530 | } else if ("LEICA".equals(cameraMake)) {
|
|---|
| 531 | // Some Leica cameras use Panasonic makernote tags
|
|---|
| 532 | pushDirectory(PanasonicMakernoteDirectory.class);
|
|---|
| 533 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
|
|---|
| 534 | } else {
|
|---|
| 535 | return false;
|
|---|
| 536 | }
|
|---|
| 537 | } else if ("Panasonic\u0000\u0000\u0000".equals(firstTwelveChars)) {
|
|---|
| 538 | // NON-Standard TIFF IFD Data using Panasonic Tags. There is no Next-IFD pointer after the IFD
|
|---|
| 539 | // Offsets are relative to the start of the TIFF header at the beginning of the EXIF segment
|
|---|
| 540 | // more information here: http://www.ozhiker.com/electronics/pjmt/jpeg_info/panasonic_mn.html
|
|---|
| 541 | pushDirectory(PanasonicMakernoteDirectory.class);
|
|---|
| 542 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 12, tiffHeaderOffset);
|
|---|
| 543 | } else if ("AOC\u0000".equals(firstFourChars)) {
|
|---|
| 544 | // NON-Standard TIFF IFD Data using Casio Type 2 Tags
|
|---|
| 545 | // IFD has no Next-IFD pointer at end of IFD, and
|
|---|
| 546 | // Offsets are relative to the start of the current IFD tag, not the TIFF header
|
|---|
| 547 | // Observed for:
|
|---|
| 548 | // - Pentax ist D
|
|---|
| 549 | pushDirectory(CasioType2MakernoteDirectory.class);
|
|---|
| 550 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 6, makernoteOffset);
|
|---|
| 551 | } else if (cameraMake != null && (cameraMake.toUpperCase().startsWith("PENTAX") || cameraMake.toUpperCase().startsWith("ASAHI"))) {
|
|---|
| 552 | // NON-Standard TIFF IFD Data using Pentax Tags
|
|---|
| 553 | // IFD has no Next-IFD pointer at end of IFD, and
|
|---|
| 554 | // Offsets are relative to the start of the current IFD tag, not the TIFF header
|
|---|
| 555 | // Observed for:
|
|---|
| 556 | // - PENTAX Optio 330
|
|---|
| 557 | // - PENTAX Optio 430
|
|---|
| 558 | pushDirectory(PentaxMakernoteDirectory.class);
|
|---|
| 559 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset, makernoteOffset);
|
|---|
| 560 | // } else if ("KC".equals(firstTwoChars) || "MINOL".equals(firstFiveChars) || "MLY".equals(firstThreeChars) || "+M+M+M+M".equals(firstEightChars)) {
|
|---|
| 561 | // // This Konica data is not understood. Header identified in accordance with information at this site:
|
|---|
| 562 | // // http://www.ozhiker.com/electronics/pjmt/jpeg_info/minolta_mn.html
|
|---|
| 563 | // // TODO add support for minolta/konica cameras
|
|---|
| 564 | // exifDirectory.addError("Unsupported Konica/Minolta data ignored.");
|
|---|
| 565 | } else if ("SANYO\0\1\0".equals(firstEightChars)) {
|
|---|
| 566 | pushDirectory(SanyoMakernoteDirectory.class);
|
|---|
| 567 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, makernoteOffset);
|
|---|
| 568 | } else if (cameraMake != null && cameraMake.toLowerCase().startsWith("ricoh")) {
|
|---|
| 569 | if (firstTwoChars.equals("Rv") || firstThreeChars.equals("Rev")) {
|
|---|
| 570 | // This is a textual format, where the makernote bytes look like:
|
|---|
| 571 | // Rv0103;Rg1C;Bg18;Ll0;Ld0;Aj0000;Bn0473800;Fp2E00:������������������������������
|
|---|
| 572 | // Rv0103;Rg1C;Bg18;Ll0;Ld0;Aj0000;Bn0473800;Fp2D05:������������������������������
|
|---|
| 573 | // Rv0207;Sf6C84;Rg76;Bg60;Gg42;Ll0;Ld0;Aj0004;Bn0B02900;Fp10B8;Md6700;Ln116900086D27;Sv263:0000000000000000000000��
|
|---|
| 574 | // This format is currently unsupported
|
|---|
| 575 | return false;
|
|---|
| 576 | } else if (firstFiveChars.equalsIgnoreCase("Ricoh")) {
|
|---|
| 577 | // Always in Motorola byte order
|
|---|
| 578 | reader.setMotorolaByteOrder(true);
|
|---|
| 579 | pushDirectory(RicohMakernoteDirectory.class);
|
|---|
| 580 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, makernoteOffset);
|
|---|
| 581 | }
|
|---|
| 582 | } else if (firstTenChars.equals("Apple iOS\0")) {
|
|---|
| 583 | // Always in Motorola byte order
|
|---|
| 584 | boolean orderBefore = reader.isMotorolaByteOrder();
|
|---|
| 585 | reader.setMotorolaByteOrder(true);
|
|---|
| 586 | pushDirectory(AppleMakernoteDirectory.class);
|
|---|
| 587 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 14, makernoteOffset);
|
|---|
| 588 | reader.setMotorolaByteOrder(orderBefore);
|
|---|
| 589 | } else if (reader.getUInt16(makernoteOffset) == ReconyxHyperFireMakernoteDirectory.MAKERNOTE_VERSION) {
|
|---|
| 590 | ReconyxHyperFireMakernoteDirectory directory = new ReconyxHyperFireMakernoteDirectory();
|
|---|
| 591 | _metadata.addDirectory(directory);
|
|---|
| 592 | processReconyxHyperFireMakernote(directory, makernoteOffset, reader);
|
|---|
| 593 | } else if (firstNineChars.equalsIgnoreCase("RECONYXUF")) {
|
|---|
| 594 | ReconyxUltraFireMakernoteDirectory directory = new ReconyxUltraFireMakernoteDirectory();
|
|---|
| 595 | _metadata.addDirectory(directory);
|
|---|
| 596 | processReconyxUltraFireMakernote(directory, makernoteOffset, reader);
|
|---|
| 597 | } else if ("SAMSUNG".equals(cameraMake)) {
|
|---|
| 598 | // Only handles Type2 notes correctly. Others aren't implemented, and it's complex to determine which ones to use
|
|---|
| 599 | pushDirectory(SamsungType2MakernoteDirectory.class);
|
|---|
| 600 | TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
|
|---|
| 601 | } else {
|
|---|
| 602 | // The makernote is not comprehended by this library.
|
|---|
| 603 | // If you are reading this and believe a particular camera's image should be processed, get in touch.
|
|---|
| 604 | return false;
|
|---|
| 605 | }
|
|---|
| 606 |
|
|---|
| 607 | reader.setMotorolaByteOrder(byteOrderBefore);
|
|---|
| 608 | return true;
|
|---|
| 609 | }
|
|---|
| 610 |
|
|---|
| 611 | private static boolean handlePrintIM(@NotNull final Directory directory, final int tagId)
|
|---|
| 612 | {
|
|---|
| 613 | if (tagId == ExifDirectoryBase.TAG_PRINT_IMAGE_MATCHING_INFO)
|
|---|
| 614 | return true;
|
|---|
| 615 |
|
|---|
| 616 | if (tagId == 0x0E00) {
|
|---|
| 617 | // Tempting to say every tagid of 0x0E00 is a PIM tag, but can't be 100% sure
|
|---|
| 618 | if (directory instanceof CasioType2MakernoteDirectory ||
|
|---|
| 619 | directory instanceof KyoceraMakernoteDirectory ||
|
|---|
| 620 | directory instanceof NikonType2MakernoteDirectory ||
|
|---|
| 621 | directory instanceof OlympusMakernoteDirectory ||
|
|---|
| 622 | directory instanceof PanasonicMakernoteDirectory ||
|
|---|
| 623 | directory instanceof PentaxMakernoteDirectory ||
|
|---|
| 624 | directory instanceof RicohMakernoteDirectory ||
|
|---|
| 625 | directory instanceof SanyoMakernoteDirectory ||
|
|---|
| 626 | directory instanceof SonyType1MakernoteDirectory)
|
|---|
| 627 | return true;
|
|---|
| 628 | }
|
|---|
| 629 |
|
|---|
| 630 | return false;
|
|---|
| 631 | }
|
|---|
| 632 |
|
|---|
| 633 | /// <summary>
|
|---|
| 634 | /// Process PrintIM IFD
|
|---|
| 635 | /// </summary>
|
|---|
| 636 | /// <remarks>
|
|---|
| 637 | /// Converted from Exiftool version 10.33 created by Phil Harvey
|
|---|
| 638 | /// http://www.sno.phy.queensu.ca/~phil/exiftool/
|
|---|
| 639 | /// lib\Image\ExifTool\PrintIM.pm
|
|---|
| 640 | /// </remarks>
|
|---|
| 641 | private static void processPrintIM(@NotNull final PrintIMDirectory directory, final int tagValueOffset, @NotNull final RandomAccessReader reader, final int byteCount) throws IOException
|
|---|
| 642 | {
|
|---|
| 643 | Boolean resetByteOrder = null;
|
|---|
| 644 |
|
|---|
| 645 | if (byteCount == 0) {
|
|---|
| 646 | directory.addError("Empty PrintIM data");
|
|---|
| 647 | return;
|
|---|
| 648 | }
|
|---|
| 649 |
|
|---|
| 650 | if (byteCount <= 15) {
|
|---|
| 651 | directory.addError("Bad PrintIM data");
|
|---|
| 652 | return;
|
|---|
| 653 | }
|
|---|
| 654 |
|
|---|
| 655 | String header = reader.getString(tagValueOffset, 12, Charsets.UTF_8);
|
|---|
| 656 |
|
|---|
| 657 | if (!header.startsWith("PrintIM")) {
|
|---|
| 658 | directory.addError("Invalid PrintIM header");
|
|---|
| 659 | return;
|
|---|
| 660 | }
|
|---|
| 661 |
|
|---|
| 662 | // check size of PrintIM block
|
|---|
| 663 | int num = reader.getUInt16(tagValueOffset + 14);
|
|---|
| 664 |
|
|---|
| 665 | if (byteCount < 16 + num * 6) {
|
|---|
| 666 | // size is too big, maybe byte ordering is wrong
|
|---|
| 667 | resetByteOrder = reader.isMotorolaByteOrder();
|
|---|
| 668 | reader.setMotorolaByteOrder(!reader.isMotorolaByteOrder());
|
|---|
| 669 | num = reader.getUInt16(tagValueOffset + 14);
|
|---|
| 670 | if (byteCount < 16 + num * 6) {
|
|---|
| 671 | directory.addError("Bad PrintIM size");
|
|---|
| 672 | return;
|
|---|
| 673 | }
|
|---|
| 674 | }
|
|---|
| 675 |
|
|---|
| 676 | directory.setObject(PrintIMDirectory.TagPrintImVersion, header.substring(8, 12));
|
|---|
| 677 |
|
|---|
| 678 | for (int n = 0; n < num; n++) {
|
|---|
| 679 | int pos = tagValueOffset + 16 + n * 6;
|
|---|
| 680 | int tag = reader.getUInt16(pos);
|
|---|
| 681 | long val = reader.getUInt32(pos + 2);
|
|---|
| 682 |
|
|---|
| 683 | directory.setObject(tag, val);
|
|---|
| 684 | }
|
|---|
| 685 |
|
|---|
| 686 | if (resetByteOrder != null)
|
|---|
| 687 | reader.setMotorolaByteOrder(resetByteOrder);
|
|---|
| 688 | }
|
|---|
| 689 |
|
|---|
| 690 | private static void processKodakMakernote(@NotNull final KodakMakernoteDirectory directory, final int tagValueOffset, @NotNull final RandomAccessReader reader)
|
|---|
| 691 | {
|
|---|
| 692 | // Kodak's makernote is not in IFD format. It has values at fixed offsets.
|
|---|
| 693 | int dataOffset = tagValueOffset + 8;
|
|---|
| 694 | try {
|
|---|
| 695 | directory.setStringValue(KodakMakernoteDirectory.TAG_KODAK_MODEL, reader.getStringValue(dataOffset, 8, Charsets.UTF_8));
|
|---|
| 696 | directory.setInt(KodakMakernoteDirectory.TAG_QUALITY, reader.getUInt8(dataOffset + 9));
|
|---|
| 697 | directory.setInt(KodakMakernoteDirectory.TAG_BURST_MODE, reader.getUInt8(dataOffset + 10));
|
|---|
| 698 | directory.setInt(KodakMakernoteDirectory.TAG_IMAGE_WIDTH, reader.getUInt16(dataOffset + 12));
|
|---|
| 699 | directory.setInt(KodakMakernoteDirectory.TAG_IMAGE_HEIGHT, reader.getUInt16(dataOffset + 14));
|
|---|
| 700 | directory.setInt(KodakMakernoteDirectory.TAG_YEAR_CREATED, reader.getUInt16(dataOffset + 16));
|
|---|
| 701 | directory.setByteArray(KodakMakernoteDirectory.TAG_MONTH_DAY_CREATED, reader.getBytes(dataOffset + 18, 2));
|
|---|
| 702 | directory.setByteArray(KodakMakernoteDirectory.TAG_TIME_CREATED, reader.getBytes(dataOffset + 20, 4));
|
|---|
| 703 | directory.setInt(KodakMakernoteDirectory.TAG_BURST_MODE_2, reader.getUInt16(dataOffset + 24));
|
|---|
| 704 | directory.setInt(KodakMakernoteDirectory.TAG_SHUTTER_MODE, reader.getUInt8(dataOffset + 27));
|
|---|
| 705 | directory.setInt(KodakMakernoteDirectory.TAG_METERING_MODE, reader.getUInt8(dataOffset + 28));
|
|---|
| 706 | directory.setInt(KodakMakernoteDirectory.TAG_SEQUENCE_NUMBER, reader.getUInt8(dataOffset + 29));
|
|---|
| 707 | directory.setInt(KodakMakernoteDirectory.TAG_F_NUMBER, reader.getUInt16(dataOffset + 30));
|
|---|
| 708 | directory.setLong(KodakMakernoteDirectory.TAG_EXPOSURE_TIME, reader.getUInt32(dataOffset + 32));
|
|---|
| 709 | directory.setInt(KodakMakernoteDirectory.TAG_EXPOSURE_COMPENSATION, reader.getInt16(dataOffset + 36));
|
|---|
| 710 | directory.setInt(KodakMakernoteDirectory.TAG_FOCUS_MODE, reader.getUInt8(dataOffset + 56));
|
|---|
| 711 | directory.setInt(KodakMakernoteDirectory.TAG_WHITE_BALANCE, reader.getUInt8(dataOffset + 64));
|
|---|
| 712 | directory.setInt(KodakMakernoteDirectory.TAG_FLASH_MODE, reader.getUInt8(dataOffset + 92));
|
|---|
| 713 | directory.setInt(KodakMakernoteDirectory.TAG_FLASH_FIRED, reader.getUInt8(dataOffset + 93));
|
|---|
| 714 | directory.setInt(KodakMakernoteDirectory.TAG_ISO_SETTING, reader.getUInt16(dataOffset + 94));
|
|---|
| 715 | directory.setInt(KodakMakernoteDirectory.TAG_ISO, reader.getUInt16(dataOffset + 96));
|
|---|
| 716 | directory.setInt(KodakMakernoteDirectory.TAG_TOTAL_ZOOM, reader.getUInt16(dataOffset + 98));
|
|---|
| 717 | directory.setInt(KodakMakernoteDirectory.TAG_DATE_TIME_STAMP, reader.getUInt16(dataOffset + 100));
|
|---|
| 718 | directory.setInt(KodakMakernoteDirectory.TAG_COLOR_MODE, reader.getUInt16(dataOffset + 102));
|
|---|
| 719 | directory.setInt(KodakMakernoteDirectory.TAG_DIGITAL_ZOOM, reader.getUInt16(dataOffset + 104));
|
|---|
| 720 | directory.setInt(KodakMakernoteDirectory.TAG_SHARPNESS, reader.getInt8(dataOffset + 107));
|
|---|
| 721 | } catch (IOException ex) {
|
|---|
| 722 | directory.addError("Error processing Kodak makernote data: " + ex.getMessage());
|
|---|
| 723 | }
|
|---|
| 724 | }
|
|---|
| 725 |
|
|---|
| 726 | private static void processReconyxHyperFireMakernote(@NotNull final ReconyxHyperFireMakernoteDirectory directory, final int makernoteOffset, @NotNull final RandomAccessReader reader) throws IOException
|
|---|
| 727 | {
|
|---|
| 728 | directory.setObject(ReconyxHyperFireMakernoteDirectory.TAG_MAKERNOTE_VERSION, reader.getUInt16(makernoteOffset));
|
|---|
| 729 |
|
|---|
| 730 | int major = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_FIRMWARE_VERSION);
|
|---|
| 731 | int minor = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_FIRMWARE_VERSION + 2);
|
|---|
| 732 | int revision = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_FIRMWARE_VERSION + 4);
|
|---|
| 733 | String buildYear = String.format("%04X", reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_FIRMWARE_VERSION + 6));
|
|---|
| 734 | String buildDate = String.format("%04X", reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_FIRMWARE_VERSION + 8));
|
|---|
| 735 | String buildYearAndDate = buildYear + buildDate;
|
|---|
| 736 | Integer build;
|
|---|
| 737 | try {
|
|---|
| 738 | build = Integer.parseInt(buildYearAndDate);
|
|---|
| 739 | } catch (NumberFormatException e) {
|
|---|
| 740 | build = null;
|
|---|
| 741 | }
|
|---|
| 742 |
|
|---|
| 743 | if (build != null) {
|
|---|
| 744 | directory.setString(ReconyxHyperFireMakernoteDirectory.TAG_FIRMWARE_VERSION, String.format("%d.%d.%d.%s", major, minor, revision, build));
|
|---|
| 745 | } else {
|
|---|
| 746 | directory.setString(ReconyxHyperFireMakernoteDirectory.TAG_FIRMWARE_VERSION, String.format("%d.%d.%d", major, minor, revision));
|
|---|
| 747 | directory.addError("Error processing Reconyx HyperFire makernote data: build '" + buildYearAndDate + "' is not in the expected format and will be omitted from Firmware Version.");
|
|---|
| 748 | }
|
|---|
| 749 |
|
|---|
| 750 | directory.setString(ReconyxHyperFireMakernoteDirectory.TAG_TRIGGER_MODE, String.valueOf((char)reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_TRIGGER_MODE)));
|
|---|
| 751 | directory.setIntArray(ReconyxHyperFireMakernoteDirectory.TAG_SEQUENCE,
|
|---|
| 752 | new int[]
|
|---|
| 753 | {
|
|---|
| 754 | reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_SEQUENCE),
|
|---|
| 755 | reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_SEQUENCE + 2)
|
|---|
| 756 | });
|
|---|
| 757 |
|
|---|
| 758 | int eventNumberHigh = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_EVENT_NUMBER);
|
|---|
| 759 | int eventNumberLow = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_EVENT_NUMBER + 2);
|
|---|
| 760 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_EVENT_NUMBER, (eventNumberHigh << 16) + eventNumberLow);
|
|---|
| 761 |
|
|---|
| 762 | int seconds = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL);
|
|---|
| 763 | int minutes = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 2);
|
|---|
| 764 | int hour = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 4);
|
|---|
| 765 | int month = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 6);
|
|---|
| 766 | int day = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 8);
|
|---|
| 767 | int year = reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 10);
|
|---|
| 768 |
|
|---|
| 769 | if ((seconds >= 0 && seconds < 60) &&
|
|---|
| 770 | (minutes >= 0 && minutes < 60) &&
|
|---|
| 771 | (hour >= 0 && hour < 24) &&
|
|---|
| 772 | (month >= 1 && month < 13) &&
|
|---|
| 773 | (day >= 1 && day < 32) &&
|
|---|
| 774 | (year >= 1 && year <= 9999)) {
|
|---|
| 775 | directory.setString(ReconyxHyperFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL,
|
|---|
| 776 | String.format("%4d:%2d:%2d %2d:%2d:%2d", year, month, day, hour, minutes, seconds));
|
|---|
| 777 | } else {
|
|---|
| 778 | directory.addError("Error processing Reconyx HyperFire makernote data: Date/Time Original " + year + "-" + month + "-" + day + " " + hour + ":" + minutes + ":" + seconds + " is not a valid date/time.");
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_MOON_PHASE, reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_MOON_PHASE));
|
|---|
| 782 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_AMBIENT_TEMPERATURE_FAHRENHEIT, reader.getInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_AMBIENT_TEMPERATURE_FAHRENHEIT));
|
|---|
| 783 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_AMBIENT_TEMPERATURE, reader.getInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_AMBIENT_TEMPERATURE));
|
|---|
| 784 | //directory.setByteArray(ReconyxHyperFireMakernoteDirectory.TAG_SERIAL_NUMBER, reader.getBytes(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_SERIAL_NUMBER, 28));
|
|---|
| 785 | directory.setStringValue(ReconyxHyperFireMakernoteDirectory.TAG_SERIAL_NUMBER, new StringValue(reader.getBytes(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_SERIAL_NUMBER, 28), Charsets.UTF_16LE));
|
|---|
| 786 | // two unread bytes: the serial number's terminating null
|
|---|
| 787 |
|
|---|
| 788 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_CONTRAST, reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_CONTRAST));
|
|---|
| 789 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_BRIGHTNESS, reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_BRIGHTNESS));
|
|---|
| 790 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_SHARPNESS, reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_SHARPNESS));
|
|---|
| 791 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_SATURATION, reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_SATURATION));
|
|---|
| 792 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_INFRARED_ILLUMINATOR, reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_INFRARED_ILLUMINATOR));
|
|---|
| 793 | directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_MOTION_SENSITIVITY, reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_MOTION_SENSITIVITY));
|
|---|
| 794 | directory.setDouble(ReconyxHyperFireMakernoteDirectory.TAG_BATTERY_VOLTAGE, reader.getUInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_BATTERY_VOLTAGE) / 1000.0);
|
|---|
| 795 | directory.setString(ReconyxHyperFireMakernoteDirectory.TAG_USER_LABEL, reader.getNullTerminatedString(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_USER_LABEL, 44, Charsets.UTF_8));
|
|---|
| 796 | }
|
|---|
| 797 |
|
|---|
| 798 | private static void processReconyxUltraFireMakernote(@NotNull final ReconyxUltraFireMakernoteDirectory directory, final int makernoteOffset, @NotNull final RandomAccessReader reader) throws IOException
|
|---|
| 799 | {
|
|---|
| 800 | directory.setString(ReconyxUltraFireMakernoteDirectory.TAG_LABEL, reader.getString(makernoteOffset, 9, Charsets.UTF_8));
|
|---|
| 801 | /*uint makernoteID = ByteConvert.FromBigEndianToNative(reader.GetUInt32(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagMakernoteID));
|
|---|
| 802 | directory.Set(ReconyxUltraFireMakernoteDirectory.TagMakernoteID, makernoteID);
|
|---|
| 803 | if (makernoteID != ReconyxUltraFireMakernoteDirectory.MAKERNOTE_ID) {
|
|---|
| 804 | directory.addError("Error processing Reconyx UltraFire makernote data: unknown Makernote ID 0x" + makernoteID.ToString("x8"));
|
|---|
| 805 | return;
|
|---|
| 806 | }
|
|---|
| 807 | directory.Set(ReconyxUltraFireMakernoteDirectory.TagMakernoteSize, ByteConvert.FromBigEndianToNative(reader.GetUInt32(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagMakernoteSize)));
|
|---|
| 808 | uint makernotePublicID = ByteConvert.FromBigEndianToNative(reader.GetUInt32(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagMakernotePublicID));
|
|---|
| 809 | directory.Set(ReconyxUltraFireMakernoteDirectory.TagMakernotePublicID, makernotePublicID);
|
|---|
| 810 | if (makernotePublicID != ReconyxUltraFireMakernoteDirectory.MAKERNOTE_PUBLIC_ID) {
|
|---|
| 811 | directory.addError("Error processing Reconyx UltraFire makernote data: unknown Makernote Public ID 0x" + makernotePublicID.ToString("x8"));
|
|---|
| 812 | return;
|
|---|
| 813 | }*/
|
|---|
| 814 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagMakernotePublicSize, ByteConvert.FromBigEndianToNative(reader.GetUInt16(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagMakernotePublicSize)));
|
|---|
| 815 |
|
|---|
| 816 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagCameraVersion, ProcessReconyxUltraFireVersion(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagCameraVersion, reader));
|
|---|
| 817 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagUibVersion, ProcessReconyxUltraFireVersion(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagUibVersion, reader));
|
|---|
| 818 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagBtlVersion, ProcessReconyxUltraFireVersion(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagBtlVersion, reader));
|
|---|
| 819 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagPexVersion, ProcessReconyxUltraFireVersion(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagPexVersion, reader));
|
|---|
| 820 |
|
|---|
| 821 | directory.setString(ReconyxUltraFireMakernoteDirectory.TAG_EVENT_TYPE, reader.getString(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_EVENT_TYPE, 1, Charsets.UTF_8));
|
|---|
| 822 | directory.setIntArray(ReconyxUltraFireMakernoteDirectory.TAG_SEQUENCE,
|
|---|
| 823 | new int[]
|
|---|
| 824 | {
|
|---|
| 825 | reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_SEQUENCE),
|
|---|
| 826 | reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_SEQUENCE + 1)
|
|---|
| 827 | });
|
|---|
| 828 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagEventNumber, ByteConvert.FromBigEndianToNative(reader.GetUInt32(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagEventNumber)));
|
|---|
| 829 |
|
|---|
| 830 | byte seconds = reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL);
|
|---|
| 831 | byte minutes = reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 1);
|
|---|
| 832 | byte hour = reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 2);
|
|---|
| 833 | byte day = reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 3);
|
|---|
| 834 | byte month = reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL + 4);
|
|---|
| 835 | /*ushort year = ByteConvert.FromBigEndianToNative(reader.GetUInt16(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagDateTimeOriginal + 5));
|
|---|
| 836 | if ((seconds >= 0 && seconds < 60) &&
|
|---|
| 837 | (minutes >= 0 && minutes < 60) &&
|
|---|
| 838 | (hour >= 0 && hour < 24) &&
|
|---|
| 839 | (month >= 1 && month < 13) &&
|
|---|
| 840 | (day >= 1 && day < 32) &&
|
|---|
| 841 | (year >= 1 && year <= 9999)) {
|
|---|
| 842 | directory.Set(ReconyxUltraFireMakernoteDirectory.TAG_DATE_TIME_ORIGINAL, new DateTime(year, month, day, hour, minutes, seconds, DateTimeKind.Unspecified));
|
|---|
| 843 | } else {
|
|---|
| 844 | directory.addError("Error processing Reconyx UltraFire makernote data: Date/Time Original " + year + "-" + month + "-" + day + " " + hour + ":" + minutes + ":" + seconds + " is not a valid date/time.");
|
|---|
| 845 | }*/
|
|---|
| 846 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagDayOfWeek, reader.GetByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagDayOfWeek));
|
|---|
| 847 |
|
|---|
| 848 | directory.setInt(ReconyxUltraFireMakernoteDirectory.TAG_MOON_PHASE, reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_MOON_PHASE));
|
|---|
| 849 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagAmbientTemperatureFahrenheit, ByteConvert.FromBigEndianToNative(reader.GetInt16(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagAmbientTemperatureFahrenheit)));
|
|---|
| 850 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagAmbientTemperature, ByteConvert.FromBigEndianToNative(reader.GetInt16(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagAmbientTemperature)));
|
|---|
| 851 |
|
|---|
| 852 | directory.setInt(ReconyxUltraFireMakernoteDirectory.TAG_FLASH, reader.getByte(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_FLASH));
|
|---|
| 853 | //directory.Set(ReconyxUltraFireMakernoteDirectory.TagBatteryVoltage, ByteConvert.FromBigEndianToNative(reader.GetUInt16(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TagBatteryVoltage)) / 1000.0);
|
|---|
| 854 | directory.setStringValue(ReconyxUltraFireMakernoteDirectory.TAG_SERIAL_NUMBER, new StringValue(reader.getBytes(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_SERIAL_NUMBER, 14), Charsets.UTF_8));
|
|---|
| 855 | // unread byte: the serial number's terminating null
|
|---|
| 856 | directory.setString(ReconyxUltraFireMakernoteDirectory.TAG_USER_LABEL, reader.getNullTerminatedString(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_USER_LABEL, 20, Charsets.UTF_8));
|
|---|
| 857 | }
|
|---|
| 858 | }
|
|---|
| 859 |
|
|---|