public VP8Frame(ImageInputStream stream, int[][][][] coefProbs) throws IOException { this.frame = stream; offset = frame.getStreamPosition(); this.coefProbs=coefProbs; tokenBoolDecoders = new Vector<BoolDecoder>(); } public void addIIOReadProgressListener(IIOReadProgressListener listener) {
public VP8Frame(ImageInputStream stream) throws IOException { this.frame = stream; offset = frame.getStreamPosition(); this.coefProbs=Globals.getDefaultCoefProbs(); tokenBoolDecoders = new Vector<BoolDecoder>(); } public VP8Frame(ImageInputStream stream, int[][][][] coefProbs) throws IOException {
public void setFrame(ImageInputStream frame) { try { this.frame.flush(); this.frame.close(); this.frame = frame; offset = frame.getStreamPosition(); this.coefProbs=Globals.getDefaultCoefProbs(); tokenBoolDecoders = new Vector<BoolDecoder>(); } catch (IOException e) { e.printStackTrace(); } } }
public void mark(int pReadLimit) { try { markPosition = input.getStreamPosition(); } catch (IOException e) { // Let's hope this never happens, because it's not possible to reset then... throw new IllegalStateException("Could not read stream position: " + e.getMessage(), e); } }
/** * Marks this stream as closed. * This implementation does <em>not</em> close the underlying stream. */ public void close() throws IOException { if (hasLength) { input.seek(input.getStreamPosition() + left); } left = 0; input = null; }
public void reset() throws IOException { long diff = input.getStreamPosition() - markPosition; input.seek(markPosition); left += diff; }
private BufferedImageInputStream(final ImageInputStream pStream, final int pBufferSize) throws IOException { stream = notNull(pStream, "stream"); streamPos = pStream.getStreamPosition(); buffer = ByteBuffer.allocate(pBufferSize); buffer.limit(0); }
static IconResource read(final ImageInputStream input) throws IOException { return read(input.getStreamPosition(), input); }
@Override public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) { super.setInput(input, seekForwardOnly, ignoreMetadata); try { if (imageInput != null) { streamOffsets.add(imageInput.getStreamPosition()); } initDelegate(seekForwardOnly, ignoreMetadata); } catch (IOException e) { // TODO: This should ideally be reported as an IOException, but I don't see how throw new IllegalStateException(e.getMessage(), e); } }
private Object readValueAt(final ImageInputStream pInput, final long pOffset, final short pType, final int pCount) throws IOException { long pos = pInput.getStreamPosition(); try { pInput.seek(pOffset); return readValue(pInput, pType, pCount); } catch (EOFException e) { // TODO: Add warning listener API and report problem to client code return e; } finally { pInput.seek(pos); } }
private void readHeader() throws IOException { if (header == null) { imageInput.setByteOrder(ByteOrder.LITTLE_ENDIAN); header = PCXHeader.read(imageInput); if (DEBUG) { System.err.println("header: " + header); } imageInput.flushBefore(imageInput.getStreamPosition()); } imageInput.seek(imageInput.getFlushedPosition()); }
private void readHeader() throws IOException { if (header == null) { header = SGIHeader.read(imageInput); // System.err.println("header: " + header); imageInput.flushBefore(imageInput.getStreamPosition()); } imageInput.seek(imageInput.getFlushedPosition()); }
private void readHeader() throws IOException { if (header == null) { header = HDRHeader.read(imageInput); imageInput.flushBefore(imageInput.getStreamPosition()); } imageInput.seek(imageInput.getFlushedPosition()); }
private void readHeader() throws IOException { assertInput(); if (header == null) { imageInput.setByteOrder(ByteOrder.LITTLE_ENDIAN); header = DCXHeader.read(imageInput); if (DEBUG) { System.err.println("header: " + header); } imageInput.flushBefore(imageInput.getStreamPosition()); } imageInput.seek(imageInput.getFlushedPosition()); }
private void readHeader() throws IOException { if (header == null) { header = HeaderParser.parse(imageInput); imageInput.flushBefore(imageInput.getStreamPosition()); imageInput.setByteOrder(header.getByteOrder()); // For PFM support } else { imageInput.seek(imageInput.getFlushedPosition()); } }
@Test public void testSeek() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); stream.seek(5); assertEquals(5, stream.getStreamPosition()); stream.seek(1); assertEquals(1, stream.getStreamPosition()); } }
@Test public void testProviderShouldNotConsumeExistingMarks() throws IOException { try (ImageInputStream stream = new ByteArrayImageInputStream(new byte[1024])) { stream.seek(42); stream.mark(); stream.seek(123); sProvider.canDecodeInput(stream); assertEquals(123, stream.getStreamPosition()); stream.reset(); assertEquals(42, stream.getStreamPosition()); } }
@Test public void testSeekBeforeFlushedPos() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); stream.seek(3); stream.flushBefore(3); assertEquals(3, stream.getStreamPosition()); try { stream.seek(0); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { assertTrue(expected.getMessage().contains("pos")); } assertEquals(3, stream.getStreamPosition()); }
@Test public void testSeekNegative() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); try { stream.seek(-2); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { assertTrue(expected.getMessage().contains("pos")); } assertEquals(0, stream.getStreamPosition()); }
@Test public void testCreate() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(11), 7); assertEquals(0, stream.getStreamPosition()); assertEquals(7, stream.length()); }