/** Read the CRC itself. Naturally, this doesn't update * the CRC. */ public long readCRC() throws IOException { long c = ModuleBase.readUnsignedInt (_dstream, true); return c; }
public static int readSignedInt (RandomAccessFile file, boolean endian) throws IOException { long b = readUnsignedInt (file, endian); if ((b & 0X80000000L) != 0) { b |= ~0XFFFFFFFFL; } return (int) b; }
/** * Reads four bytes as an unsigned 32-bit 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 long readUnsignedInt (DataInputStream stream, boolean bigEndian) throws IOException { return readUnsignedInt (stream, bigEndian, null); }
public static Rational readUnsignedRational (RandomAccessFile file, boolean endian) throws IOException { long n = readUnsignedInt (file, endian); long d = readUnsignedInt (file, endian); return new Rational (n, d); }
/** Reads a RATIONAL value and returns it as a Rational. */ protected Rational readRational(long count, long value) throws IOException { _raf.seek(value); long numer = ModuleBase.readUnsignedInt(_raf, _bigEndian); long denom = ModuleBase.readUnsignedInt(_raf, _bigEndian); return new Rational(numer, denom); }
public static Rational readUnsignedRational (DataInputStream stream, boolean endian, ModuleBase counted) throws IOException { long n = readUnsignedInt (stream, endian, counted); long d = readUnsignedInt (stream, endian, counted); return new Rational (n, d); }
public static int readSignedInt (DataInputStream stream, boolean endian, ModuleBase counted) throws IOException { long b = readUnsignedInt (stream, endian, counted); if ((b & 0X80000000L) != 0) { b |= ~0XFFFFFFFFL; } return (int) b; }
/** Reads an array of RATIONAL values and returns it as an * array of Rational. */ protected Rational [] readRationalArray(long count, long value) throws IOException { _raf.seek(value); byte [] buffer = new byte [(int) calcValueSize(RATIONAL, count)]; _raf.read(buffer); DataInputStream stream = new DataInputStream(new ByteArrayInputStream(buffer)); Rational [] rarray = new Rational [(int) count]; for (int i=0; i<count; i++) { long numer = ModuleBase.readUnsignedInt (stream, _bigEndian, null); long denom = ModuleBase.readUnsignedInt (stream, _bigEndian, null); rarray[i] = new Rational(numer, denom); } return rarray; }
private static void readNestedChunks (String ckID, DataInputStream stream, long ckSize, long os) throws IOException { String listType = read4Chars (stream); System.out.println ("List type = " + listType); while (ckSize > 0) { String subCkID = read4Chars (stream); long subCkSize = ModuleBase.readUnsignedInt (stream, ENDIAN, null); System.out.println (leading (os, 8) + os + ": " + ckID + "/" + subCkID + " " + subCkSize); stream.skipBytes ((int) subCkSize); os += subCkSize + 8; ckSize -= subCkSize + 8; } }
/** Reads a box header and sets up for reading contents. */ public void read () throws IOException { length = ModuleBase.readUnsignedInt (dstream, ENDIAN, null); long headerLength = 8; type = read4Chars (); // If the length field is 1, there is an 8-byte extended // length field. if (length == 1) { length = ModuleBase.readSignedLong(dstream, true, null); headerLength = 16; } bytesLeft = length - headerLength; }
/** * Reads 8 bytes from the beginning of the box and parses * out the box length and type. */ public void readHeader () throws IOException { _length = ModuleBase.readUnsignedInt(_dstream, true, _module); _type = _module.read4Chars (_dstream); // If the length field is 1, there is an 8-byte extended // length field. if (_length == 1) { _length = ModuleBase.readSignedLong(_dstream, true, _module); _headerLength = 16; } else { _headerLength = 8; } }
/** 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; }
long offset = ModuleBase.readUnsignedInt (file, bigEndian); _tags.put ("00000000", "\"" + ((char) b1) + ((char) b2) + "\" (" + (bigEndian ? "big" : "little") + " endian) " + magic +
long ckSize = ModuleBase.readUnsignedInt (stream, ENDIAN); os += 4; ckSize = ModuleBase.readUnsignedInt (stream, ENDIAN); System.out.print (leading (os, 8) + os + ": " + ckID + " " + ckSize); if ("fact".equals (ckID)) { long sampleLength = ModuleBase.readUnsignedInt (stream, ENDIAN); System.out.print (": " + sampleLength); alreadyRead = 4; ENDIAN); long samplesPerSec = ModuleBase.readUnsignedInt (stream, ENDIAN); long avgBytesPerSec = ModuleBase.readUnsignedInt (stream, ENDIAN); int blockAlign = ModuleBase.readUnsignedShort (stream, ENDIAN); ENDIAN); long channelMask = ModuleBase.readUnsignedInt (stream, ENDIAN); hex = Long.toHexString (channelMask); for (int i=0; i<4; i++) { long guid =
/** * Reads the header of a chunk. If _chunkID is non-null, * it's assumed to have already been read. */ public boolean readHeader (DataInputStream dstrm) throws IOException { StringBuffer id = new StringBuffer(4); for (int i = 0; i < 4; i++) { int ch = ModuleBase.readUnsignedByte (dstrm, _module); if (ch < 32) { String hx = Integer.toHexString (ch); if (hx.length () < 2) { hx = "0" + hx; } _repInfo.setMessage (new ErrorMessage (MessageConstants.ERR_CHUNK_ID_CHAR_INV, MessageConstants.ERR_CHUNK_ID_CHAR_SUB + hx, _module.getNByte ())); _repInfo.setWellFormed (false); return false; } id.append((char) ch); } _chunkID = id.toString (); _size = ModuleBase.readUnsignedInt (dstrm, _module.isBigEndian (), _module); return true; }
int tag = ModuleBase.readUnsignedShort (file, bigEndian); int type = ModuleBase.readUnsignedShort (file, bigEndian); long count = ModuleBase.readUnsignedInt (file, bigEndian); if (type == IFD.ASCII) { if (count > 4) { long vo = ModuleBase.readUnsignedInt (file, bigEndian); file.seek (vo); type == IFD.UNDEFINED) { if (count > 4) { long vo = ModuleBase.readUnsignedInt (file, bigEndian); file.seek (vo); long vo = ModuleBase.readUnsignedInt (file, bigEndian); file.seek (vo); long vo = ModuleBase.readUnsignedInt (file, bigEndian); file.seek (vo); long vo = ModuleBase.readUnsignedInt (file, bigEndian); file.seek (vo); long in = ModuleBase.readUnsignedInt (file, bigEndian); if (j > 0) { buffer.append (" "); long vo = ModuleBase.readUnsignedInt (file, bigEndian); file.seek (vo);
long ckSize = ModuleBase.readUnsignedInt (stream, ENDIAN); ckSize = ModuleBase.readUnsignedInt (stream, ENDIAN); System.out.print (leading (os, 8) + os + ": " + ckID + " " + ckSize); ENDIAN); long numSampleFrames = ModuleBase.readUnsignedInt (stream, ENDIAN); int sampleSize = ModuleBase.readSignedShort (stream, ENDIAN); long timestamp = ModuleBase.readUnsignedInt (stream, ENDIAN, null); long offset = ModuleBase.readUnsignedInt (stream, ENDIAN); long blockSize = ModuleBase.readUnsignedInt (stream, ENDIAN); System.out.print (": " + offset + " " + blockSize);
_next = ModuleBase.readUnsignedInt(_raf, _bigEndian); long count = ModuleBase.readUnsignedInt(ifdStream, _bigEndian, null); long value = ModuleBase.readUnsignedInt(ifdStream, _bigEndian, null); if (calcValueSize(type, count) > 4) {