SeekableStream seekableStream = new FileSeekableStream(new File("front.jpg")); ParameterBlock pb = new ParameterBlock(); pb.add(seekableStream); BufferedImage image = JAI.create("jpeg", pb).getAsBufferedImage();
protected SeekableInputStream makeInputStream(final InputStream pStream) { try { return new FileSeekableStream(createFileWithContent(pStream)); } catch (IOException e) { throw new RuntimeException(e); } }
@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; }
protected SeekableInputStream makeInputStream(final InputStream pStream) { try { return new FileSeekableStream(createFileWithContent(pStream)); } catch (IOException e) { throw new RuntimeException(e); } }
SeekableStream ss = new FileSeekableStream(file[i]); ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", ss, null);
protected SeekableInputStream makeInputStream(final InputStream pStream) { try { return new FileSeekableStream(createFileWithContent(pStream)); } catch (IOException e) { throw new RuntimeException(e); } }
File file = new File("input.tif"); try { SeekableStream s = new FileSeekableStream(file); TIFFDecodeParam param = null; ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, param);
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);
SeekableStream seekableStream = new FileSeekableStream(file); ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", seekableStream, null); int numPages = decoder.getNumPages();
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]); } }