Java Code Examples for javax.imageio.plugins.tiff.TIFFField#getAsLong()
The following examples show how to use
javax.imageio.plugins.tiff.TIFFField#getAsLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TIFFImageReader.java From Bytecoder with Apache License 2.0 | 6 votes |
private long getTileOrStripOffset(int tileIndex) throws IIOException { TIFFField f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_TILE_OFFSETS); if (f == null) { f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_OFFSETS); } if (f == null) { f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_JPEG_INTERCHANGE_FORMAT); } if (f == null) { throw new IIOException("Missing required strip or tile offsets field."); } return f.getAsLong(tileIndex); }
Example 2
Source File: TIFFImageReader.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private long getTileOrStripOffset(int tileIndex) throws IIOException { TIFFField f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_TILE_OFFSETS); if (f == null) { f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_OFFSETS); } if (f == null) { f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_JPEG_INTERCHANGE_FORMAT); } if (f == null) { throw new IIOException("Missing required strip or tile offsets field."); } return f.getAsLong(tileIndex); }
Example 3
Source File: TIFFImageReader.java From Bytecoder with Apache License 2.0 | 5 votes |
private long getTileOrStripByteCount(int tileIndex) throws IOException { TIFFField f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS); if (f == null) { f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS); } if (f == null) { f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH); } long tileOrStripByteCount; if (f != null) { tileOrStripByteCount = f.getAsLong(tileIndex); } else { processWarningOccurred("TIFF directory contains neither StripByteCounts nor TileByteCounts field: attempting to calculate from strip or tile width and height."); // Initialize to number of bytes per strip or tile assuming // no compression. int bitsPerPixel = bitsPerSample[0]; for (int i = 1; i < samplesPerPixel; i++) { bitsPerPixel += bitsPerSample[i]; } int bytesPerRow = (getTileOrStripWidth() * bitsPerPixel + 7) / 8; tileOrStripByteCount = bytesPerRow * getTileOrStripHeight(); // Clamp to end of stream if possible. long streamLength = stream.length(); if (streamLength != -1) { tileOrStripByteCount = Math.min(tileOrStripByteCount, streamLength - getTileOrStripOffset(tileIndex)); } else { processWarningOccurred("Stream length is unknown: cannot clamp estimated strip or tile byte count to EOF."); } } return tileOrStripByteCount; }
Example 4
Source File: TIFFImageReader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private long getTileOrStripByteCount(int tileIndex) throws IOException { TIFFField f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS); if (f == null) { f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS); } if (f == null) { f = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH); } long tileOrStripByteCount; if (f != null) { tileOrStripByteCount = f.getAsLong(tileIndex); } else { processWarningOccurred("TIFF directory contains neither StripByteCounts nor TileByteCounts field: attempting to calculate from strip or tile width and height."); // Initialize to number of bytes per strip or tile assuming // no compression. int bitsPerPixel = bitsPerSample[0]; for (int i = 1; i < samplesPerPixel; i++) { bitsPerPixel += bitsPerSample[i]; } int bytesPerRow = (getTileOrStripWidth() * bitsPerPixel + 7) / 8; tileOrStripByteCount = bytesPerRow * getTileOrStripHeight(); // Clamp to end of stream if possible. long streamLength = stream.length(); if (streamLength != -1) { tileOrStripByteCount = Math.min(tileOrStripByteCount, streamLength - getTileOrStripOffset(tileIndex)); } else { processWarningOccurred("Stream length is unknown: cannot clamp estimated strip or tile byte count to EOF."); } } return tileOrStripByteCount; }
Example 5
Source File: TIFFIFD.java From Bytecoder with Apache License 2.0 | 4 votes |
private long getFieldAsLong(int tagNumber) { TIFFField f = getTIFFField(tagNumber); return f == null ? -1 : f.getAsLong(0); }
Example 6
Source File: TIFFIFD.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private long getFieldAsLong(int tagNumber) { TIFFField f = getTIFFField(tagNumber); return f == null ? -1 : f.getAsLong(0); }