public static int readSignedShort (RandomAccessFile file, boolean endian) throws IOException { int b = readUnsignedShort (file, endian); if ((b & 0X8000) != 0) { b |= ~0XFFFF; } return b; }
/** * Reads two bytes as an unsigned short value from a DataInputStream. * @param stream The stream to read from. * @param bigEndian If true, interpret the first byte as the high * byte, otherwise interpret the first byte as * the low byte. */ public static int readUnsignedShort (DataInputStream stream, boolean bigEndian) throws IOException { return readUnsignedShort (stream, bigEndian, null); }
/** * Read marker segment data * @param stream Data input stream * @param bigEndian True if big-endian * @return Length of marker segment */ private static int markerSegment (DataInputStream stream, boolean bigEndian) throws IOException { int length = ModuleBase.readUnsignedShort (stream, bigEndian, null); for (int i=2; i<length; i++) { stream.readUnsignedByte (); } return length; } }
public static int readSignedShort (DataInputStream stream, boolean endian, ModuleBase counted) throws IOException { int b = readUnsignedShort (stream, endian, counted); if ((b & 0X8000) != 0) { b |= ~0XFFFF; } return b; }
/** Reads an unsigned number of any type. * @param type TIFF type to read */ public long readUnsigned(int type) throws IOException { long u = 0L; switch (type) { case BYTE: case UNDEFINED: u = ModuleBase.readUnsignedByte(_raf); break; case SHORT: u = ModuleBase.readUnsignedShort(_raf, _bigEndian); break; case LONG: case IFD: u = ModuleBase.readUnsignedInt(_raf, _bigEndian); break; } return u; }
bigEndian = false; int magic = ModuleBase.readUnsignedShort (file, bigEndian); long offset = ModuleBase.readUnsignedInt (file, bigEndian); _tags.put ("00000000", "\"" + ((char) b1) + ((char) b2) + "\" (" +
int formatTag = ModuleBase.readUnsignedShort (stream, ENDIAN); int channels = ModuleBase.readUnsignedShort (stream, ENDIAN); long samplesPerSec = long avgBytesPerSec = ModuleBase.readUnsignedInt (stream, ENDIAN); int blockAlign = ModuleBase.readUnsignedShort (stream, ENDIAN); String hex = Integer.toHexString (formatTag); if (ckSize > 14) { int bitsPerSample = ModuleBase.readUnsignedShort (stream, ENDIAN); System.out.print (" " + bitsPerSample); alreadyRead = 16; if (ckSize > 16) { int size = ModuleBase.readUnsignedShort (stream, ENDIAN); System.out.print (" " + size); if (size == 22) { int validBitsPerSample = ModuleBase.readUnsignedShort (stream, ENDIAN); long channelMask =
int width = ModuleBase.readUnsignedShort(stream, bigEndian, null); int height = ModuleBase.readUnsignedShort(stream, bigEndian, null); int packedFields = stream.readUnsignedByte (); int backgroundColor = stream.readUnsignedByte (); int imageLeft = ModuleBase.readUnsignedShort (stream, bigEndian, null); int imageTop = ModuleBase.readUnsignedShort (stream, bigEndian, null); int imageWidth = ModuleBase.readUnsignedShort (stream, bigEndian, null); int imageHeight = ModuleBase.readUnsignedShort (stream, bigEndian, null); int gridLeft = ModuleBase.readUnsignedShort(stream, bigEndian, null); int gridTop = ModuleBase.readUnsignedShort(stream, bigEndian, null); int gridWidth = ModuleBase.readUnsignedShort(stream, bigEndian, null); int gridHeight= ModuleBase.readUnsignedShort(stream, bigEndian,
int nEntries = ModuleBase.readUnsignedShort (file, bigEndian); _tags.put (leading (offset, 8) + offset, "IFD " + nIFD + " with " + nEntries + " entries"); long os = offset + 2 + i*12; file.seek (os); int tag = ModuleBase.readUnsignedShort (file, bigEndian); int type = ModuleBase.readUnsignedShort (file, bigEndian); long count = ModuleBase.readUnsignedInt (file, bigEndian); int sh = ModuleBase.readUnsignedShort (file, bigEndian); buffer.append (" " + sh);
int numComments = ModuleBase.readUnsignedShort (stream, ENDIAN, null); int numMarkers = ModuleBase.readUnsignedShort (stream, ENDIAN); System.out.print (": " + numMarkers);
int length = ModuleBase.readUnsignedShort (stream, bigEndian, null); int P = stream.readUnsignedByte (); int Y = ModuleBase.readUnsignedShort (stream, bigEndian, null); int X = ModuleBase.readUnsignedShort (stream, bigEndian, null); int Nf = stream.readUnsignedByte (); int length = ModuleBase.readUnsignedShort (stream, bigEndian, null); int minor = stream.readUnsignedByte (); int units = stream.readUnsignedByte (); int xDensity = ModuleBase.readUnsignedShort (stream, bigEndian, null); int yDensity = ModuleBase.readUnsignedShort (stream, bigEndian, null); int length = ModuleBase.readUnsignedShort (stream, bigEndian, null); int length = ModuleBase.readUnsignedShort (stream, bigEndian,
try { _raf.seek(offset); nFields = ModuleBase.readUnsignedShort(_raf, _bigEndian); offset += 2; int prevTag = 0; for (int i=0; i<nFields; i++) { int tag = ModuleBase.readUnsignedShort(ifdStream, _bigEndian, null); int type = ModuleBase.readUnsignedShort(ifdStream, _bigEndian, null);