SeekableStream seekableStream = new FileSeekableStream(new File("front.jpg")); ParameterBlock pb = new ParameterBlock(); pb.add(seekableStream); BufferedImage image = JAI.create("jpeg", pb).getAsBufferedImage();
public int read() throws IOException { checkOpen(); int read = mRandomAccess.read(); if (read >= 0) { position++; } return read; }
@Test public void testCloseUnderlyingFile() throws IOException { final boolean[] closed = new boolean[1]; File file = createFileWithContent(new ByteArrayInputStream(makeRandomArray(256))); RandomAccessFile raf = new RandomAccessFile(file, "r") { @Override public void close() throws IOException { closed[0] = true; super.close(); } }; FileSeekableStream stream = new FileSeekableStream(raf); try { FileUtil.read(stream); // Read until EOF assertEquals("EOF not reached (test case broken)", -1, stream.read()); assertFalse("Underlying stream closed before close", closed[0]); } finally { stream.close(); } assertTrue("Underlying stream not closed", closed[0]); } }
import com.sun.media.jai.codec.FileSeekableStream; import com.sun.media.jai.codec.ImageCodec; import com.sun.media.jai.codec.ImageDecoder; // This function is minimal, you should add exceptions and error handling public RenderedImage read(String filename) FileSeekableStream fss = new FileSeekableStream(filename); ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", fss, null); RenderedImage image = decoder.decodeAsRenderedImage() fss.close(); return image; }
public void testCloseUnderlyingFile() throws IOException { final boolean[] closed = new boolean[1]; File file = createFileWithContent(new ByteArrayInputStream(makeRandomArray(256))); RandomAccessFile raf = new RandomAccessFile(file, "r") { @Override public void close() throws IOException { closed[0] = true; super.close(); } }; FileSeekableStream stream = new FileSeekableStream(raf); try { FileUtil.read(stream); // Read until EOF assertEquals("EOF not reached (test case broken)", -1, stream.read()); assertFalse("Underlying stream closed before close", closed[0]); } finally { stream.close(); } assertTrue("Underlying stream not closed", closed[0]); } }
@Test public void testCloseUnderlyingFile() throws IOException { final boolean[] closed = new boolean[1]; File file = createFileWithContent(new ByteArrayInputStream(makeRandomArray(256))); RandomAccessFile raf = new RandomAccessFile(file, "r") { @Override public void close() throws IOException { closed[0] = true; super.close(); } }; FileSeekableStream stream = new FileSeekableStream(raf); try { FileUtil.read(stream); // Read until EOF assertEquals("EOF not reached (test case broken)", -1, stream.read()); assertFalse("Underlying stream closed before close", closed[0]); } finally { stream.close(); } assertTrue("Underlying stream not closed", closed[0]); } }
protected SeekableInputStream makeInputStream(final InputStream pStream) { try { return new FileSeekableStream(createFileWithContent(pStream)); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public int read(byte pBytes[], int pOffset, int pLength) throws IOException { checkOpen(); int read = mRandomAccess.read(pBytes, pOffset, pLength); if (read > 0) { position += read; } return read; }
protected SeekableInputStream makeInputStream(final InputStream pStream) { try { return new FileSeekableStream(createFileWithContent(pStream)); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public int read(byte pBytes[], int pOffset, int pLength) throws IOException { checkOpen(); int read = mRandomAccess.read(pBytes, pOffset, pLength); if (read > 0) { mPosition += read; } return read; }
protected SeekableInputStream makeInputStream(final InputStream pStream) { try { return new FileSeekableStream(createFileWithContent(pStream)); } catch (IOException e) { throw new RuntimeException(e); } }
public int read() throws IOException { checkOpen(); int read = mRandomAccess.read(); if (read >= 0) { position++; } return read; }
SeekableStream ss = new FileSeekableStream(file[i]); ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", ss, null);
@Override public int read(byte pBytes[], int pOffset, int pLength) throws IOException { checkOpen(); int read = mRandomAccess.read(pBytes, pOffset, pLength); if (read > 0) { position += read; } return read; }
File file = new File("input.tif"); try { SeekableStream s = new FileSeekableStream(file); TIFFDecodeParam param = null; ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, param);
public int read() throws IOException { checkOpen(); int read = mRandomAccess.read(); if (read >= 0) { mPosition++; } return read; }
fileSeekableStream = new FileSeekableStream(file.getCanonicalPath());
PlanarImage op = null; for (int i = 0; i < allFiles.size(); i++) { ss = new FileSeekableStream(folderBase + "\\" + allFiles.get(i)); ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", ss, null); op = new NullOpImage(decoder.decodeAsRenderedImage(0),
SeekableStream ss = new FileSeekableStream(tiff); ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", ss, null); int numPages = decoder.getNumPages();
SeekableStream s = new FileSeekableStream(file);