/** * Reads a private IFD from a given offset in the stream. This * method may be used to obtain IFDs that are referenced * only by private tag values. */ public TIFFDirectory getPrivateIFD(long offset) throws IOException { return new TIFFDirectory(stream, offset, 0); }
/** * Returns the value of index 0 of a given tag as a * byte. The caller is responsible for ensuring that the tag is * present and has type TIFFField.TIFF_SBYTE, TIFF_BYTE, or * TIFF_UNDEFINED. */ public byte getFieldAsByte(int tag) { return getFieldAsByte(tag, 0); }
/** * Returns the value of index 0 of a given tag as a double. The * caller is responsible for ensuring that the tag is present and * has numeric type (all but TIFF_UNDEFINED and TIFF_ASCII). */ public double getFieldAsDouble(int tag) { return getFieldAsDouble(tag, 0); }
if (!isValidEndianTag(endian)) { throw new IllegalArgumentException(PropertyUtil.getString("TIFFDirectory1")); int magic = readUnsignedShort(stream); if (magic != 42) { throw new IllegalArgumentException(PropertyUtil.getString("TIFFDirectory2")); ifdOffset = readUnsignedInt(stream); long entries = readUnsignedShort(stream); stream.skip(12 * entries); ifdOffset = readUnsignedInt(stream); initialize(stream); stream.seek(globalSaveOffset);
TIFFDirectory dir; try { dir = new TIFFDirectory(seekable, pageIndex); } catch (IllegalArgumentException iae) { String errorMessage = MessageFormat.format( int width = (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_WIDTH); int height = (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_LENGTH); ImageSize size = new ImageSize(); size.setSizeInPixels(width, height); int unit = 2; //inch is default if (dir.isTagPresent(TIFFImageDecoder.TIFF_RESOLUTION_UNIT)) { unit = (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_RESOLUTION_UNIT); TIFFField fldx = dir.getField(TIFFImageDecoder.TIFF_X_RESOLUTION); TIFFField fldy = dir.getField(TIFFImageDecoder.TIFF_Y_RESOLUTION); if (fldx == null || fldy == null) { unit = 2; fld = dir.getField(TIFFImageDecoder.TIFF_COMPRESSION); if (fld != null) { int compression = fld.getAsInt(0); fld = dir.getField(TIFFImageDecoder.TIFF_TILE_WIDTH); if (fld != null) { if (log.isTraceEnabled()) { fld = dir.getField(TIFFImageDecoder.TIFF_ROWS_PER_STRIP); if (fld == null) {
? new TIFFDirectory(stream, directory) : new TIFFDirectory(stream, param.getIFDOffset(), directory); TIFFField sfield = dir.getField(TIFFImageDecoder.TIFF_SAMPLES_PER_PIXEL); int samplesPerPixel = sfield == null ? 1 : (int)sfield.getAsLong(0); dir.getField(TIFFImageDecoder.TIFF_PLANAR_CONFIGURATION); char[] planarConfiguration = planarConfigurationField == null ? new char[] {1} dir.getField(TIFFImageDecoder.TIFF_BITS_PER_SAMPLE); char[] bitsPerSample = null; if (bitsField != null) { dir.getField(TIFFImageDecoder.TIFF_SAMPLE_FORMAT); TIFFField compField = dir.getField(TIFFImageDecoder.TIFF_COMPRESSION); compression = compField == null ? COMP_NONE : compField.getAsInt(0); TIFFField photometricTypeField = dir.getField( TIFFImageDecoder.TIFF_PHOTOMETRIC_INTERPRETATION); if (photometricTypeField == null) { (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_WIDTH), (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_LENGTH)); TIFFField efield = dir.getField(TIFFImageDecoder.TIFF_EXTRA_SAMPLES); int extraSamples = efield == null ? 0 : (int)efield.getAsLong(0);
try { SeekableStream seekable = new SeekableStreamAdapter(in); dir = new TIFFDirectory(seekable, 0); TIFFField fld; fld = dir.getField(TIFFImageDecoder.TIFF_COMPRESSION); if (fld != null) { compression = fld.getAsInt(0); fld = dir.getField(TIFFImageDecoder.TIFF_T4_OPTIONS); if (fld != null) { long t4Options = fld.getAsLong(0); fld = dir.getField(TIFFImageDecoder.TIFF_FILL_ORDER); if (fld != null) { fillOrder = fld.getAsInt(0); fld = dir.getField(TIFFImageDecoder.TIFF_ROWS_PER_STRIP); if (fld == null) { stripCount = 1; "ImageLoader doesn't support multiple strips"); stripOffset = dir.getField(TIFFImageDecoder.TIFF_STRIP_OFFSETS).getAsLong(0); stripLength = dir.getField(TIFFImageDecoder.TIFF_STRIP_BYTE_COUNTS).getAsLong(0); } finally { in.reset();
/** * Returns the value of index 0 of a given tag as a float. The * caller is responsible for ensuring that the tag is present and * has numeric type (all but TIFF_UNDEFINED and TIFF_ASCII). */ public float getFieldAsFloat(int tag) { return getFieldAsFloat(tag, 0); }
public int getNumPages() throws IOException { return TIFFDirectory.getNumDirectories(input); }
/** * Returns the value of index 0 of a given tag as a * long. The caller is responsible for ensuring that the tag is * present and has type TIFF_BYTE, TIFF_SBYTE, TIFF_UNDEFINED, * TIFF_SHORT, TIFF_SSHORT, TIFF_SLONG or TIFF_LONG. */ public long getFieldAsLong(int tag) { return getFieldAsLong(tag, 0); }
stream.seek(0L); int endian = stream.readUnsignedShort(); if (!isValidEndianTag(endian)) { throw new IllegalArgumentException(PropertyUtil.getString("TIFFDirectory1")); while (dirNum < directory) { long numEntries = readUnsignedShort(stream); ifdOffset = readUnsignedInt(stream); initialize(stream); stream.seek(globalSaveOffset);