/** * Creates a new DataChunk at the current position of the * ImageOutputStream. * * @param chunkType The chunkType of the chunk. */ public DataChunk(String name) throws IOException { super(name); out.writeLong(0); // make room for the chunk header }
public void writeLong(long v) throws IOException { ios.writeLong(v); }
public void writeLong(long v) throws IOException { ios.writeLong(v); }
/** * Creates a new CompositeChunk at the current position of the * ImageOutputStream. * * @param compositeType The type of the composite. * @param chunkType The type of the chunk. */ public CompositeChunk(int compositeType, int chunkType) throws IOException { super(chunkType); this.compositeType = compositeType; //out.write out.writeLong(0); // make room for the chunk header out.writeInt(0); // make room for the chunk header children = new LinkedList<Chunk>(); }
/** * Creates a new CompositeChunk at the current position of the * ImageOutputStream. * * @param compositeType The type of the composite. * @param chunkType The type of the chunk. */ public CompositeChunk(String compositeType, String chunkType) throws IOException { super(chunkType); this.compositeType = compositeType; //out.write out.writeLong(0); // make room for the chunk header out.writeInt(0); // make room for the chunk header }
/** * Creates a new CompositeChunk at the current position of the * ImageOutputStream. * * @param compositeType The type of the composite. * @param chunkType The type of the chunk. */ public CompositeChunk(String compositeType, String chunkType) throws IOException { super(chunkType); this.compositeType = compositeType; //out.write out.writeLong(0); // make room for the chunk header out.writeInt(0); // make room for the chunk header children = new LinkedList<Chunk>(); }
/** * Creates a new CompositeChunk at the current position of the * ImageOutputStream. * * @param compositeType The type of the composite. * @param chunkType The type of the chunk. * @throws java.io.IOException TODO */ public CompositeChunk(int compositeType, int chunkType) throws IOException { super(chunkType); this.compositeType = compositeType; //out.write out.writeLong(0); // make room for the chunk header out.writeInt(0); // make room for the chunk header children = new LinkedList<Chunk>(); }
public CommonAtom(AtomType type, ImageOutputStream imageOutputStream) { super(type, imageOutputStream); try { int headerSize = getHeaderElements(); for (int i = 0; i < headerSize; i++) { out.writeLong(0); // make room for the atom header } } catch (IOException e) { throw new IORuntimeException(e); } }
/** * Creates a new DataAtom at the current position of the * ImageOutputStream. * * @param type The type of the atom. */ public WideDataAtom(String type) throws IOException { super(type, getRelativeStreamPosition()); out.writeLong(0); // make room for the atom header out.writeLong(0); // make room for the atom header data = new DataAtomOutputStream(new ImageOutputStreamAdapter(out)) { @Override public void flush() throws IOException { // DO NOT FLUSH UNDERLYING STREAM! } }; }
/** * Creates a new DataAtom at the current position of the * ImageOutputStream. * * @param type The type of the atom. * @throws java.io.IOException TODO */ public WideDataAtom(String type) throws IOException { super(type, getRelativeStreamPosition()); out.writeLong(0); // make room for the atom header out.writeLong(0); // make room for the atom header data = new DataAtomOutputStream(new ImageOutputStreamAdapter(out)) { @Override public void flush() throws IOException { // DO NOT FLUSH UNDERLYING STREAM! } }; }
/** * Creates a new DataChunk at the current position of the * ImageOutputStream. * * @param chunkType The chunkType of the chunk. */ public DataChunk(String name) throws IOException { super(name); out.writeLong(0); // make room for the chunk header data = new DataChunkOutputStream(new ImageOutputStreamAdapter(out), false); }
/** Writes this box instance into a <code>ImageOutputStream</code>. */ public void write(ImageOutputStream ios) throws IOException { ios.writeInt(length); ios.writeInt(type); if (length == 1) { ios.writeLong(extraLength); ios.write(data, 0, (int)extraLength); } else if (data != null) ios.write(data, 0, length); }
/** * Creates a new DataAtom at the current position of the * ImageOutputStream. * * @param type The type name of the atom. */ public DataAtom(String type) throws IOException { super(type, getRelativeStreamPosition()); out.writeLong(0); // make room for the atom header data = new DataAtomOutputStream(new ImageOutputStreamAdapter(out)); }
/** Writes this box instance into a <code>ImageOutputStream</code>. */ public void write(ImageOutputStream ios) throws IOException { ios.writeInt(length); ios.writeInt(type); if (length == 1) { ios.writeLong(extraLength); ios.write(data, 0, (int)extraLength); } else if (data != null) ios.write(data, 0, length); }
/** Writes this box instance into a <code>ImageOutputStream</code>. */ public void write(ImageOutputStream ios) throws IOException { ios.writeInt(length); ios.writeInt(type); if (length == 1) { ios.writeLong(extraLength); ios.write(data, 0, (int)extraLength); } else if (data != null) ios.write(data, 0, length); }
/** Writes this box instance into a <code>ImageOutputStream</code>. */ public void write(ImageOutputStream ios) throws IOException { ios.writeInt(length); ios.writeInt(type); if (length == 1) { ios.writeLong(extraLength); ios.write(data, 0, (int)extraLength); } else if (data != null) ios.write(data, 0, length); }
/** Writes this box instance into a <code>ImageOutputStream</code>. */ public void write(ImageOutputStream ios) throws IOException { ios.writeInt(length); ios.writeInt(type); if (length == 1) { ios.writeLong(extraLength); ios.write(data, 0, (int)extraLength); } else if (data != null) ios.write(data, 0, length); }
/** * Creates a new DataAtom at the current position of the * ImageOutputStream. * * @param type The type name of the atom. * @throws java.io.IOException TODO */ public DataAtom(String type) throws IOException { super(type, getRelativeStreamPosition()); out.writeLong(0); // make room for the atom header data = new DataAtomOutputStream(new ImageOutputStreamAdapter(out)); }
private void writeHeader() throws IOException { if (streamMetadata != null) { this.byteOrder = streamMetadata.byteOrder; } else { this.byteOrder = ByteOrder.BIG_ENDIAN; } stream.setByteOrder(byteOrder); if (byteOrder == ByteOrder.BIG_ENDIAN) { stream.writeShort(0x4d4d); } else { stream.writeShort(0x4949); } if(!isBtiff){ stream.writeShort(42); stream.writeInt(0); nextSpace = stream.getStreamPosition(); headerPosition = nextSpace - 8; } else { stream.writeShort(43); stream.writeShort(8); stream.writeShort(0); stream.writeLong(0); nextSpace = stream.getStreamPosition(); headerPosition = nextSpace - 16; } }
/** * Invokes {@link ChannelImageOutputStream#reset()} {@code nbMarks} times and verify that the stream position * is the expected one. This method will then write random values at those positions, and finally compare the * stream content. */ private void compareMarks(int nbMarks) throws IOException { final ImageOutputStream referenceStream = (ImageOutputStream) this.referenceStream; while (--nbMarks >= 0) { referenceStream.reset(); testedStream.reset(); assertEquals(referenceStream.getBitOffset(), testedStream.getBitOffset()); assertEquals(referenceStream.getStreamPosition(), testedStream.getStreamPosition()); final long v = random.nextLong(); referenceStream.writeLong(v); testedStream.writeLong(v); } /* * Verify that we have no remaining marks, and finally compare stream content. */ try { testedStream.reset(); fail("Expected no remaining marks."); } catch (InvalidMarkException e) { // This is the expected exception. } assertStreamContentEquals(); }