private int readInt(RandomAccessFileOrArray stream) throws IOException { if (isBigEndian) { return stream.readInt(); } else { return stream.readIntLE(); } }
private int readInt(RandomAccessFileOrArray stream) throws IOException { if (isBigEndian) { return stream.readInt(); } else { return stream.readIntLE(); } }
public float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); }
public float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); }
int getInt() { try { return buf.readInt(); } catch (Exception e) { throw new ExceptionConverter(e); } }
HashMap<Integer, int[]> readFormat12() throws IOException { HashMap<Integer, int[]> h = new HashMap<Integer, int[]>(); rf.skipBytes(2); int table_lenght = rf.readInt(); rf.skipBytes(4); int nGroups = rf.readInt(); for (int k = 0; k < nGroups; k++) { int startCharCode = rf.readInt(); int endCharCode = rf.readInt(); int startGlyphID = rf.readInt(); for (int i = startCharCode; i <= endCharCode; i++) { int[] r = new int[2]; r[0] = startGlyphID; r[1] = getGlyphWidth(r[0]); h.put(Integer.valueOf(i), r); startGlyphID++; } } return h; }
int getInt() { try { return buf.readInt(); } catch (Exception e) { throw new ExceptionConverter(e); } }
HashMap<Integer, int[]> readFormat12() throws IOException { HashMap<Integer, int[]> h = new HashMap<Integer, int[]>(); rf.skipBytes(2); int table_lenght = rf.readInt(); rf.skipBytes(4); int nGroups = rf.readInt(); for (int k = 0; k < nGroups; k++) { int startCharCode = rf.readInt(); int endCharCode = rf.readInt(); int startGlyphID = rf.readInt(); for (int i = startCharCode; i <= endCharCode; i++) { int[] r = new int[2]; r[0] = startGlyphID; r[1] = getGlyphWidth(r[0]); h.put(Integer.valueOf(i), r); startGlyphID++; } } return h; }
protected void createTableDirectory() throws IOException, DocumentException { tableDirectory = new HashMap<String, int[]>(); rf.seek(directoryOffset); int id = rf.readInt(); if (id != 0x00010000) throw new DocumentException(MessageLocalization.getComposedMessage("1.is.not.a.true.type.file", fileName)); int num_tables = rf.readUnsignedShort(); rf.skipBytes(6); for (int k = 0; k < num_tables; ++k) { String tag = readStandardString(4); int tableLocation[] = new int[3]; tableLocation[TABLE_CHECKSUM] = rf.readInt(); tableLocation[TABLE_OFFSET] = rf.readInt(); tableLocation[TABLE_LENGTH] = rf.readInt(); tableDirectory.put(tag, tableLocation); } }
protected void createTableDirectory() throws IOException, DocumentException { tableDirectory = new HashMap<String, int[]>(); rf.seek(directoryOffset); int id = rf.readInt(); if (id != 0x00010000) throw new DocumentException(MessageLocalization.getComposedMessage("1.is.not.a.true.type.file", fileName)); int num_tables = rf.readUnsignedShort(); rf.skipBytes(6); for (int k = 0; k < num_tables; ++k) { String tag = readStandardString(4); int tableLocation[] = new int[3]; tableLocation[TABLE_CHECKSUM] = rf.readInt(); tableLocation[TABLE_OFFSET] = rf.readInt(); tableLocation[TABLE_LENGTH] = rf.readInt(); tableDirectory.put(tag, tableLocation); } }
void readSegment(JBIG2Segment s) throws IOException { int ptr = (int)ra.getFilePointer(); if ( s.dataLength == 0xffffffffl ) { // TODO figure this bit out, 7.2.7 return; } byte[] data = new byte[(int)s.dataLength]; ra.read(data); s.data = data; if ( s.type == PAGE_INFORMATION ) { int last = (int)ra.getFilePointer(); ra.seek(ptr); int page_bitmap_width = ra.readInt(); int page_bitmap_height = ra.readInt(); ra.seek(last); JBIG2Page p = pages.get(Integer.valueOf(s.page)); if ( p == null ) { throw new IllegalStateException(MessageLocalization.getComposedMessage("referring.to.widht.height.of.page.we.havent.seen.yet.1", s.page)); } p.pageBitmapWidth = page_bitmap_width; p.pageBitmapHeight = page_bitmap_height; } }
void readSegment(JBIG2Segment s) throws IOException { int ptr = (int)ra.getFilePointer(); if ( s.dataLength == 0xffffffffl ) { // TODO figure this bit out, 7.2.7 return; } byte[] data = new byte[(int)s.dataLength]; ra.read(data); s.data = data; if ( s.type == PAGE_INFORMATION ) { int last = (int)ra.getFilePointer(); ra.seek(ptr); int page_bitmap_width = ra.readInt(); int page_bitmap_height = ra.readInt(); ra.seek(last); JBIG2Page p = pages.get(Integer.valueOf(s.page)); if ( p == null ) { throw new IllegalStateException(MessageLocalization.getComposedMessage("referring.to.widht.height.of.page.we.havent.seen.yet.1", s.page)); } p.pageBitmapWidth = page_bitmap_width; p.pageBitmapHeight = page_bitmap_height; } }
void readFileHeader() throws IOException { ra.seek(0); byte[] idstring = new byte[8]; ra.read(idstring); byte[] refidstring = {(byte)0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A}; for ( int i = 0; i < idstring.length; i++ ) { if ( idstring[i] != refidstring[i] ) { throw new IllegalStateException(MessageLocalization.getComposedMessage("file.header.idstring.not.good.at.byte.1", i)); } } int fileheaderflags = ra.read(); this.sequential = ( fileheaderflags & 0x1 ) == 0x1; this.number_of_pages_known = ( fileheaderflags & 0x2) == 0x0; if ( (fileheaderflags & 0xfc) != 0x0 ) { throw new IllegalStateException(MessageLocalization.getComposedMessage("file.header.flags.bits.2.7.not.0")); } if ( this.number_of_pages_known ) { this.number_of_pages = ra.readInt(); } }
void readFileHeader() throws IOException { ra.seek(0); byte[] idstring = new byte[8]; ra.read(idstring); byte[] refidstring = {(byte)0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A}; for ( int i = 0; i < idstring.length; i++ ) { if ( idstring[i] != refidstring[i] ) { throw new IllegalStateException(MessageLocalization.getComposedMessage("file.header.idstring.not.good.at.byte.1", i)); } } int fileheaderflags = ra.read(); this.sequential = ( fileheaderflags & 0x1 ) == 0x1; this.number_of_pages_known = ( fileheaderflags & 0x2) == 0x0; if ( (fileheaderflags & 0xfc) != 0x0 ) { throw new IllegalStateException(MessageLocalization.getComposedMessage("file.header.flags.bits.2.7.not.0")); } if ( this.number_of_pages_known ) { this.number_of_pages = ra.readInt(); } }
private TableHeader readHeader() throws IOException { rf.seek(tableLocation); // 32 bit signed int version = rf.readInt(); // 16 bit unsigned int scriptListOffset = rf.readUnsignedShort(); int featureListOffset = rf.readUnsignedShort(); int lookupListOffset = rf.readUnsignedShort(); // LOG.debug("version=" + version); // LOG.debug("scriptListOffset=" + scriptListOffset); // LOG.debug("featureListOffset=" + featureListOffset); // LOG.debug("lookupListOffset=" + lookupListOffset); TableHeader header = new TableHeader(version, scriptListOffset, featureListOffset, lookupListOffset); return header; }
private TableHeader readHeader() throws IOException { rf.seek(tableLocation); // 32 bit signed int version = rf.readInt(); // 16 bit unsigned int scriptListOffset = rf.readUnsignedShort(); int featureListOffset = rf.readUnsignedShort(); int lookupListOffset = rf.readUnsignedShort(); // LOG.debug("version=" + version); // LOG.debug("scriptListOffset=" + scriptListOffset); // LOG.debug("featureListOffset=" + featureListOffset); // LOG.debug("lookupListOffset=" + lookupListOffset); TableHeader header = new TableHeader(version, scriptListOffset, featureListOffset, lookupListOffset); return header; }
protected void readLoca() throws IOException, DocumentException { int tableLocation[]; tableLocation = tableDirectory.get("head"); if (tableLocation == null) throw new DocumentException(MessageLocalization.getComposedMessage("table.1.does.not.exist.in.2", "head", fileName)); rf.seek(tableLocation[TABLE_OFFSET] + HEAD_LOCA_FORMAT_OFFSET); locaShortTable = rf.readUnsignedShort() == 0; tableLocation = tableDirectory.get("loca"); if (tableLocation == null) throw new DocumentException(MessageLocalization.getComposedMessage("table.1.does.not.exist.in.2", "loca", fileName)); rf.seek(tableLocation[TABLE_OFFSET]); if (locaShortTable) { int entries = tableLocation[TABLE_LENGTH] / 2; locaTable = new int[entries]; for (int k = 0; k < entries; ++k) locaTable[k] = rf.readUnsignedShort() * 2; } else { int entries = tableLocation[TABLE_LENGTH] / 4; locaTable = new int[entries]; for (int k = 0; k < entries; ++k) locaTable[k] = rf.readInt(); } }
protected void readLoca() throws IOException, DocumentException { int tableLocation[]; tableLocation = tableDirectory.get("head"); if (tableLocation == null) throw new DocumentException(MessageLocalization.getComposedMessage("table.1.does.not.exist.in.2", "head", fileName)); rf.seek(tableLocation[TABLE_OFFSET] + HEAD_LOCA_FORMAT_OFFSET); locaShortTable = rf.readUnsignedShort() == 0; tableLocation = tableDirectory.get("loca"); if (tableLocation == null) throw new DocumentException(MessageLocalization.getComposedMessage("table.1.does.not.exist.in.2", "loca", fileName)); rf.seek(tableLocation[TABLE_OFFSET]); if (locaShortTable) { int entries = tableLocation[TABLE_LENGTH] / 2; locaTable = new int[entries]; for (int k = 0; k < entries; ++k) locaTable[k] = rf.readUnsignedShort() * 2; } else { int entries = tableLocation[TABLE_LENGTH] / 4; locaTable = new int[entries]; for (int k = 0; k < entries; ++k) locaTable[k] = rf.readInt(); } }