List of usage examples for javax.imageio.stream MemoryCacheImageInputStream MemoryCacheImageInputStream
public MemoryCacheImageInputStream(InputStream stream)
From source file:org.olat.core.commons.services.image.spi.ImageHelperImpl.java
/** * // w w w.j a v a 2 s.co m * @param leaf * @return */ private ImageInputStream getInputStream(VFSLeaf leaf) throws IOException { if (leaf == null) { return null; } if (leaf instanceof LocalFileImpl) { LocalFileImpl file = (LocalFileImpl) leaf; if (file.getBasefile() != null) { return new FileImageInputStream(file.getBasefile()); } return null; } InputStream ins = leaf.getInputStream(); if (ins == null) { return null; } return new MemoryCacheImageInputStream(leaf.getInputStream()); }
From source file:org.opencastproject.videosegmenter.impl.jmf.ImageUtils.java
/** * Convers the frame buffer to a <code>BufferedImage</code>. This method returns <code>null</code> if the buffer * couldn't be created/* w w w. j a va 2 s. c o m*/ * * @param buf * the buffer * @return a <code>BufferedImage</code> */ public static BufferedImage createImage(Buffer buf) throws IOException { InputStream is = new ByteArrayInputStream((byte[]) buf.getData()); BufferedImage bufferedImage = ImageIO.read(new MemoryCacheImageInputStream(is)); return bufferedImage; }
From source file:VASSAL.tools.io.IOUtilsTest.java
@Test public void testCloseQuietlyImageInputStreamOpen() { final ImageInputStream in = new MemoryCacheImageInputStream(new NullInputStream(1000)); IOUtils.closeQuietly(in);/*ww w . jav a2 s. c om*/ try { in.close(); fail(); } catch (IOException e) { // This, oddly, the expected behavior of close(). } }
From source file:VASSAL.tools.io.IOUtilsTest.java
@Test public void testCloseQuietlyImageInputStreamClosed() throws IOException { final ImageInputStream in = new MemoryCacheImageInputStream(new ClosedInputStream()); in.close();/*www.j a v a2 s . c o m*/ IOUtils.closeQuietly(in); }