Java 类javax.imageio.stream.ImageInputStream 实例源码

项目:fwm    文件:AddableImage.java   
public File addImageExtension(File incoming) throws IOException {

    String format = null;
    ImageInputStream iis = ImageIO.createImageInputStream(incoming);
    Iterator<ImageReader> imageReaders = ImageIO.getImageReaders(iis);
    while (imageReaders.hasNext()) {
        ImageReader reader = (ImageReader) imageReaders.next();
        format = reader.getFormatName().toLowerCase();
        log.debug("filetype is: " + format);

        File newfile = new File("imageimage." + format);
        if (newfile.exists()) {
            newfile.delete();       
        }

        Files.copy(incoming.toPath(), newfile.toPath());
        incoming.delete();

        return newfile;
    }
    return null;

}
项目:openjdk-jdk10    文件:PNGImageReaderSpi.java   
public boolean canDecodeInput(Object input) throws IOException {
    if (!(input instanceof ImageInputStream)) {
        return false;
    }

    ImageInputStream stream = (ImageInputStream)input;
    byte[] b = new byte[8];
    stream.mark();
    stream.readFully(b);
    stream.reset();

    return (b[0] == (byte)137 &&
            b[1] == (byte)80 &&
            b[2] == (byte)78 &&
            b[3] == (byte)71 &&
            b[4] == (byte)13 &&
            b[5] == (byte)10 &&
            b[6] == (byte)26 &&
            b[7] == (byte)10);
}
项目:projectindoorweb    文件:TransformationHelper.java   
/**
 * Extracts the picture size of a given Image.
 *
 * @param path Path to the image
 * @return Image-size in pixel
 * @throws IOException Throws exception when file-access fails
 */
public static Dimension getPictureSize(final String path) throws IOException {
    try (ImageInputStream in = ImageIO.createImageInputStream(path)) {
        final Iterator<ImageReader> readers = ImageIO.getImageReaders(in);
        if (readers.hasNext()) {
            ImageReader reader = readers.next();
            try {
                reader.setInput(in);
                return new Dimension(reader.getWidth(0), reader.getHeight(0));
            } finally {
                reader.dispose();
            }
        }
        return null;
    }
}
项目:VASSAL-src    文件:IOUtils.java   
/**
 * Close an {@link ImageInputStream} unconditionally. Equivalent to
 * calling <code>s.close()</code> when <code>s</code> is nonnull.
 * {@link IOException}s are quietly logged, as there is generally
 * nothing that can be done about exceptions on closing.
 *
 * @param s a (possibly <code>null</code>) <code>ImageInputStream</code>
 */
// Why doesn't ImageInputStream implement Closeable? Argh!
public static void closeQuietly(ImageInputStream s) {
  if (s == null) return;

  try {
    s.close();
  }
  catch (IOException e) {
    // ignore

    // Note that ImageInputStreamImpl.close() rather ridiculously throws
    // an IOException if the stream is already closed. This is always done
    // via ImageInputStreamImpl.checkClosed().
  }
}
项目:openjdk-jdk10    文件:ConcurrentReadingTest.java   
public static void main(String[] args) throws Exception {
    createTestFile();

    ImageInputStream iis = ImageIO.createImageInputStream(file);
    r = ImageIO.getImageReaders(iis).next();
    iis.close();

    for (int i = 0; i < MAX_THREADS; i++) {
        (new ConcurrentReadingTest()).start();
    }

    // wait for started threads
    boolean needWait = true;
    while (needWait) {
        Thread.sleep(100);
        synchronized(lock) {
            needWait = completeCount < MAX_THREADS;
        }
    }
    System.out.println("Test PASSED.");
}
项目:SpotSpotter    文件:File2ImageReader.java   
public static ImageReader F2IR(String input) throws IOException {

        final File file = new File(input);

        // ��ȡͼƬ��ʽ
        final String formatname = GetPostfix.fromFilepath(input);

        Iterator<ImageReader> readers;
        ImageReader reader;
        ImageInputStream iis;
        readers = ImageIO.getImageReadersByFormatName(formatname);
        reader = readers.next();
        iis = ImageIO.createImageInputStream(file);
        reader.setInput(iis, false);

        return reader;
    }
项目:OpenJSharp    文件:InputImageTests.java   
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context)ctx;
    final ImageReader reader = ictx.reader;
    final boolean seekForwardOnly = ictx.seekForwardOnly;
    final boolean ignoreMetadata = ictx.ignoreMetadata;
    do {
        try {
            ImageInputStream iis = ictx.createImageInputStream();
            reader.setInput(iis, seekForwardOnly, ignoreMetadata);
            reader.read(0);
            reader.reset();
            iis.close();
            ictx.closeOriginalStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
项目:OpenJSharp    文件:InputImageTests.java   
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context)ctx;
    final ImageReader reader = ictx.reader;
    final boolean seekForwardOnly = ictx.seekForwardOnly;
    final boolean ignoreMetadata = ictx.ignoreMetadata;
    do {
        try {
            ImageInputStream iis = ictx.createImageInputStream();
            reader.setInput(iis, seekForwardOnly, ignoreMetadata);
            reader.getImageMetadata(0);
            reader.reset();
            iis.close();
            ictx.closeOriginalStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
项目:openjdk-jdk10    文件:GetReaderWriterInfoNullTest.java   
public TestImageReaderSpi(String[] FORMATNAMES, String[] SUFFIXES,
                          String[] MIMETYPES) {
    super("J Duke",          // vendor
          "1.0",             // version
          FORMATNAMES,       // format names
          SUFFIXES,          // file suffixes
          MIMETYPES,         // mimetypes
          "readTest.TestImageReader",    // reader class name
          new Class<?>[] { ImageInputStream.class }, // input types
          null,              // writer class names.
          true,              // supports native metadata,
          null,              // [no] native stream metadata format
          null,              // [no] native stream metadata class
          null,              // [no] native extra stream metadata format
          null,              // [no] native extra stream metadata class
          true,              // supports standard metadata,
          null,              // metadata format name,
          null,              // metadata format class name
          null,              // [no] extra image metadata format
          null               // [no] extra image metadata format class
     );
}
项目:jdk8u-jdk    文件:ImageIO.java   
/**
 * Returns a <code>BufferedImage</code> as the result of decoding
 * a supplied <code>ImageInputStream</code> with an
 * <code>ImageReader</code> chosen automatically from among those
 * currently registered.  If no registered
 * <code>ImageReader</code> claims to be able to read the stream,
 * <code>null</code> is returned.
 *
 * <p> Unlike most other methods in this class, this method <em>does</em>
 * close the provided <code>ImageInputStream</code> after the read
 * operation has completed, unless <code>null</code> is returned,
 * in which case this method <em>does not</em> close the stream.
 *
 * @param stream an <code>ImageInputStream</code> to read from.
 *
 * @return a <code>BufferedImage</code> containing the decoded
 * contents of the input, or <code>null</code>.
 *
 * @exception IllegalArgumentException if <code>stream</code> is
 * <code>null</code>.
 * @exception IOException if an error occurs during reading.
 */
public static BufferedImage read(ImageInputStream stream)
    throws IOException {
    if (stream == null) {
        throw new IllegalArgumentException("stream == null!");
    }

    Iterator iter = getImageReaders(stream);
    if (!iter.hasNext()) {
        return null;
    }

    ImageReader reader = (ImageReader)iter.next();
    ImageReadParam param = reader.getDefaultReadParam();
    reader.setInput(stream, true, true);
    BufferedImage bi;
    try {
        bi = reader.read(0, param);
    } finally {
        reader.dispose();
        stream.close();
    }
    return bi;
}
项目:openjdk-jdk10    文件:ImageStreamFromRAF.java   
public static void main(String[] args) {
    try {
        File f = new File("ImageInputStreamFromRAF.tmp");
        RandomAccessFile raf = new RandomAccessFile(f, "rw");
        ImageInputStream istream = ImageIO.createImageInputStream(raf);
        ImageOutputStream ostream = ImageIO.createImageOutputStream(raf);
        f.delete();
        if (istream == null) {
            throw new RuntimeException("ImageIO.createImageInputStream(RandomAccessFile) returned null!");
        }
        if (ostream == null) {
            throw new RuntimeException("ImageIO.createImageOutputStream(RandomAccessFile) returned null!");
        }
        if (!(istream instanceof FileImageInputStream)) {
            throw new RuntimeException("ImageIO.createImageInputStream(RandomAccessFile) did not return a FileImageInputStream!");
        }
        if (!(ostream instanceof FileImageOutputStream)) {
            throw new RuntimeException("ImageIO.createImageOutputStream(RandomAccessFile) did not return a FileImageOutputStream!");
        }
    } catch (IOException ioe) {
        throw new RuntimeException("Unexpected IOException: " + ioe);
    }
}
项目:OpenJSharp    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:imageio-jnr    文件:OpenJp2ImageReaderSpi.java   
@Override
public boolean canDecodeInput(Object input) throws IOException {
  if (!(input instanceof ImageInputStream)) {
    input = ImageIO.createImageInputStream(input);
  }
  if (input == null) {
    return false;
  }
  ImageInputStream stream = (ImageInputStream)input;
  byte[] b = new byte[12];
  try {
    stream.mark();
    stream.readFully(b);
  } catch (IOException e) {
    return false;
  }
  return Arrays.equals(b, HEADER_MAGIC);
}
项目:OpenJSharp    文件:JPEGImageReader.java   
public void setInput(Object input,
                     boolean seekForwardOnly,
                     boolean ignoreMetadata)
{
    setThreadLock();
    try {
        cbLock.check();

        super.setInput(input, seekForwardOnly, ignoreMetadata);
        this.ignoreMetadata = ignoreMetadata;
        resetInternalState();
        iis = (ImageInputStream) input; // Always works
        setSource(structPointer);
    } finally {
        clearThreadLock();
    }
}
项目:OpenJSharp    文件:JFIFMarkerSegment.java   
BufferedImage getThumbnail(ImageInputStream iis,
                           int index,
                           JPEGImageReader reader) throws IOException {
    reader.thumbnailStarted(index);
    BufferedImage ret = null;
    if ((thumb != null) && (index == 0)) {
            ret = thumb.getThumbnail(iis, reader);
    } else {
        if (thumb != null) {
            index--;
        }
        JFIFExtensionMarkerSegment jfxx =
            (JFIFExtensionMarkerSegment) extSegments.get(index);
        ret = jfxx.thumb.getThumbnail(iis, reader);
    }
    reader.thumbnailComplete();
    return ret;
}
项目:OpenJSharp    文件:JFIFMarkerSegment.java   
void readByteBuffer(ImageInputStream iis,
                    byte [] data,
                    JPEGImageReader reader,
                    float workPortion,
                    float workOffset) throws IOException {
    int progInterval = Math.max((int)(data.length/20/workPortion),
                                1);
    for (int offset = 0;
         offset < data.length;) {
        int len = Math.min(progInterval, data.length-offset);
        iis.read(data, offset, len);
        offset += progInterval;
        float percentDone = ((float) offset* 100)
            / data.length
            * workPortion + workOffset;
        if (percentDone > 100.0F) {
            percentDone = 100.0F;
        }
        reader.thumbnailProgress (percentDone);
    }
}
项目:OpenJSharp    文件:JPEGImageReaderSpi.java   
public JPEGImageReaderSpi() {
    super(JPEG.vendor,
          JPEG.version,
          JPEG.names,
          JPEG.suffixes,
          JPEG.MIMETypes,
          "com.sun.imageio.plugins.jpeg.JPEGImageReader",
          new Class[] { ImageInputStream.class },
          writerSpiNames,
          true,
          JPEG.nativeStreamMetadataFormatName,
          JPEG.nativeStreamMetadataFormatClassName,
          null, null,
          true,
          JPEG.nativeImageMetadataFormatName,
          JPEG.nativeImageMetadataFormatClassName,
          null, null
          );
}
项目:OpenJSharp    文件:JPEGImageReaderSpi.java   
public boolean canDecodeInput(Object source) throws IOException {
    if (!(source instanceof ImageInputStream)) {
        return false;
    }
    ImageInputStream iis = (ImageInputStream) source;
    iis.mark();
    // If the first two bytes are a JPEG SOI marker, it's probably
    // a JPEG file.  If they aren't, it definitely isn't a JPEG file.
    int byte1 = iis.read();
    int byte2 = iis.read();
    iis.reset();
    if ((byte1 == 0xFF) && (byte2 == JPEG.SOI)) {
        return true;
    }
    return false;
}
项目:OpenJSharp    文件:GIFImageReaderSpi.java   
public GIFImageReaderSpi() {
    super(vendorName,
          version,
          names,
          suffixes,
          MIMETypes,
          readerClassName,
          new Class[] { ImageInputStream.class },
          writerSpiNames,
          true,
          GIFStreamMetadata.nativeMetadataFormatName,
          "com.sun.imageio.plugins.gif.GIFStreamMetadataFormat",
          null, null,
          true,
          GIFImageMetadata.nativeMetadataFormatName,
          "com.sun.imageio.plugins.gif.GIFImageMetadataFormat",
          null, null
          );
}
项目:OpenJSharp    文件:GIFImageReader.java   
public void setInput(Object input,
                     boolean seekForwardOnly,
                     boolean ignoreMetadata) {
    super.setInput(input, seekForwardOnly, ignoreMetadata);
    if (input != null) {
        if (!(input instanceof ImageInputStream)) {
            throw new IllegalArgumentException
                ("input not an ImageInputStream!");
        }
        this.stream = (ImageInputStream)input;
    } else {
        this.stream = null;
    }

    // Clear all values based on the previous stream contents
    resetStreamSettings();
}
项目:openjdk-jdk10    文件:MarkTryFinallyReproducer.java   
public MarkTryFinallyReproducerSpi() {
    super("MarkTryFinallyReproducerSpi",
            "1.0",
            localNames,
            localSuffixes,
            localMIMETypes,
            readerClassName,
            new Class[]{ImageInputStream.class},
            new String[0],
            false,
            null,
            null,
            new String[0],
            new String[0],
            false,
            null,
            null,
            new String[0],
            new String[0]);
}
项目:openjdk-jdk10    文件:PNGImageReaderSpi.java   
public PNGImageReaderSpi() {
    super(vendorName,
          version,
          names,
          suffixes,
          MIMETypes,
          readerClassName,
          new Class<?>[] { ImageInputStream.class },
          writerSpiNames,
          false,
          null, null,
          null, null,
          true,
          PNGMetadata.nativeMetadataFormatName,
          "com.sun.imageio.plugins.png.PNGMetadataFormat",
          null, null
          );
}
项目:openjdk-jdk10    文件:ITXtTest.java   
private static ITXtTest readFrom(File f) {
    try (ImageInputStream imageInputStream =
            ImageIO.createImageInputStream(f)) {

        ImageReader r = ImageIO.getImageReaders(imageInputStream).next();
        r.setInput(imageInputStream);

        IIOImage dst = r.readAll(0, null);

        // look for iTXt node
        IIOMetadata m = dst.getMetadata();
        Node root = m.getAsTree(m.getNativeMetadataFormatName());
        Node n = root.getFirstChild();
        while (n != null && !"iTXt".equals(n.getNodeName())) {
            n = n.getNextSibling();
        }
        if (n == null) {
            throw new RuntimeException("No iTXt node!");
        }
        ITXtTest t = ITXtTest.getFromNode((IIOMetadataNode)n);
        return t;
    } catch (Throwable e) {
        throw new RuntimeException("Reading test failed.", e);
    }
}
项目:openjdk-jdk10    文件:TIFFImageReaderSpi.java   
public TIFFImageReaderSpi() {
    super("Oracle Corporation",
          "1.0",
          new String[] {"tif", "TIF", "tiff", "TIFF"},
          new String[] {"tif", "tiff"},
          new String[] {"image/tiff"},
          "com.sun.imageio.plugins.tiff.TIFFImageReader",
          new Class<?>[] { ImageInputStream.class },
          new String[] {"com.sun.imageio.plugins.tiff.TIFFImageWriterSpi"},
          false,
          TIFFStreamMetadata.NATIVE_METADATA_FORMAT_NAME,
          "com.sun.imageio.plugins.tiff.TIFFStreamMetadataFormat",
          null, null,
          true,
          TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME,
          "com.sun.imageio.plugins.tiff.TIFFImageMetadataFormat",
          null, null
          );
}
项目:OpenJSharp    文件:PNGImageReaderSpi.java   
public PNGImageReaderSpi() {
    super(vendorName,
          version,
          names,
          suffixes,
          MIMETypes,
          readerClassName,
          new Class[] { ImageInputStream.class },
          writerSpiNames,
          false,
          null, null,
          null, null,
          true,
          PNGMetadata.nativeMetadataFormatName,
          "com.sun.imageio.plugins.png.PNGMetadataFormat",
          null, null
          );
}
项目:jdk8u-jdk    文件:ShortStreamTest.java   
public void test() {
    boolean gotException = false;

    ImageInputStream iis = createShortStream();

    try {
        testRead(iis);
    } catch (IOException e) {
        e.printStackTrace(System.out);
        gotException = true;
    }

    if (!gotException) {
        throw new RuntimeException("Test failed.");
    }
    System.out.println("Test PASSED");
}
项目:jdk8u-jdk    文件:PNGImageReaderSpi.java   
public boolean canDecodeInput(Object input) throws IOException {
    if (!(input instanceof ImageInputStream)) {
        return false;
    }

    ImageInputStream stream = (ImageInputStream)input;
    byte[] b = new byte[8];
    stream.mark();
    stream.readFully(b);
    stream.reset();

    return (b[0] == (byte)137 &&
            b[1] == (byte)80 &&
            b[2] == (byte)78 &&
            b[3] == (byte)71 &&
            b[4] == (byte)13 &&
            b[5] == (byte)10 &&
            b[6] == (byte)26 &&
            b[7] == (byte)10);
}
项目:openjdk-jdk10    文件:TruncatedImageWarningTest.java   
public static void main(String[] args) throws IOException {

        String sep = System.getProperty("file.separator");
        String dir = System.getProperty("test.src", ".");
        String filePath = dir+sep+fileName;
        System.out.println("Test file: " + filePath);
        File f = new File(filePath);
        ImageInputStream in = ImageIO.createImageInputStream(f);
        ImageReader reader = ImageIO.getImageReaders(in).next();
        TruncatedImageWarningTest twt = new TruncatedImageWarningTest();
        reader.addIIOReadWarningListener(twt);
        reader.setInput(in);
        reader.read(0);
        if (!twt.receivedWarning) {
            throw new RuntimeException("No expected warning");
        }
    }
项目:openjdk-jdk10    文件:RegisterPluginTwiceTest.java   
public boolean canDecodeInput(Object input) throws IOException {
    if (!(input instanceof ImageInputStream)) {
        return false;
    }

    ImageInputStream stream = (ImageInputStream)input;
    byte[] b = new byte[8];
    stream.mark();
    stream.readFully(b);
    stream.reset();

    return (b[0] == (byte)137 &&
            b[1] == (byte)80 &&
            b[2] == (byte)78 &&
            b[3] == (byte)71 &&
            b[4] == (byte)13 &&
            b[5] == (byte)10 &&
            b[6] == (byte)26 &&
            b[7] == (byte)10);
}
项目:springboot-training    文件:ImageUtil.java   
/**
 * 获取图片的尺寸
 * 
 * @param extName
 *            后缀名
 * @param imgContent
 *            图片内容
 * @return 数组:[宽,高]
 */
public int[] getSize(String extName, byte[] imgContent) {
    if (imgContent == null || WakaUtils.string.isEmpty(extName)) {
        throw new ZhhrUtilException("获取文件大小失败!入参为空");
    }
    // 字节转图片流
    try (ImageInputStream imgInputStream = byteArrayStreamToImageInputStream(imgContent)) {
        // 取得图片读取器
        ImageReader imgReader = getImageReader(extName);

        // 把文件流加载到图片读取器中
        imgReader.setInput(imgInputStream, true);

        return new int[] { imgReader.getWidth(0), imgReader.getHeight(0) };
    } catch (IOException e) {
        throw new ZhhrUtilException(e.getMessage(), e);
    }
}
项目:openjdk-jdk10    文件:EmbeddedFormatTest.java   
public void doTest(String compression, int bi_type) throws IOException {
    System.out.println("Test " + compression + " on " + getImageTypeName(bi_type));
    BufferedImage src = createTestImage(bi_type);
    writer.reset();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageOutputStream ios =
            ImageIO.createImageOutputStream(baos);
    writer.setOutput(ios);

    ImageWriteParam wparam = prepareWriteParam(compression);
    writer.write(null, new IIOImage(src, null, null), wparam);
    ios.flush();
    ios.close();

    // read result
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ImageInputStream iis = ImageIO.createImageInputStream(bais);
    reader.reset();
    reader.setInput(iis);

    BufferedImage dst = reader.read(0);

    checkResult(dst);
}
项目:jdk8u-jdk    文件:Main.java   
public void launch(HashMap<String, ImageInputStream> refs) {
    System.out.printf("%s: current context class loader: %s\n",
                      uniqClassName,
            Thread.currentThread().getContextClassLoader());
    try {
        byte[] data = new byte[1024];
        ByteArrayInputStream bais = new ByteArrayInputStream(data);
        MyImageInputStream iis = new MyImageInputStream(bais,
                                                        uniqClassName,
                                                        problems);
        if (refs != null) {
            System.out.printf("%s: added to strong store\n",
                              uniqClassName);
            refs.put(uniqClassName, iis);
        }
        iis.read();
        //leave stream open : let's shutdown hook work!
    } catch (IOException e) {
        problems.add(e);
    }
}
项目:jdk8u-jdk    文件:InputImageTests.java   
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context)ctx;
    final ImageReader reader = ictx.reader;
    final boolean seekForwardOnly = ictx.seekForwardOnly;
    final boolean ignoreMetadata = ictx.ignoreMetadata;
    do {
        try {
            ImageInputStream iis = ictx.createImageInputStream();
            reader.setInput(iis, seekForwardOnly, ignoreMetadata);
            reader.getImageMetadata(0);
            reader.reset();
            iis.close();
            ictx.closeOriginalStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
项目:jdk8u-jdk    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk-jdk10    文件:BMPImageReaderSpi.java   
public BMPImageReaderSpi() {
    super("Oracle Corporation",
          "1.0",
          formatNames,
          entensions,
          mimeType,
          "com.sun.imageio.plugins.bmp.BMPImageReader",
          new Class<?>[] { ImageInputStream.class },
          writerSpiNames,
          false,
          null, null, null, null,
          true,
          BMPMetadata.nativeMetadataFormatName,
          "com.sun.imageio.plugins.bmp.BMPMetadataFormat",
          null, null);
}
项目:jdk8u-jdk    文件:JPEGImageReaderSpi.java   
public JPEGImageReaderSpi() {
    super(JPEG.vendor,
          JPEG.version,
          JPEG.names,
          JPEG.suffixes,
          JPEG.MIMETypes,
          "com.sun.imageio.plugins.jpeg.JPEGImageReader",
          new Class[] { ImageInputStream.class },
          writerSpiNames,
          true,
          JPEG.nativeStreamMetadataFormatName,
          JPEG.nativeStreamMetadataFormatClassName,
          null, null,
          true,
          JPEG.nativeImageMetadataFormatName,
          JPEG.nativeImageMetadataFormatClassName,
          null, null
          );
}
项目:jdk8u-jdk    文件:GIFImageReaderSpi.java   
public GIFImageReaderSpi() {
    super(vendorName,
          version,
          names,
          suffixes,
          MIMETypes,
          readerClassName,
          new Class[] { ImageInputStream.class },
          writerSpiNames,
          true,
          GIFStreamMetadata.nativeMetadataFormatName,
          "com.sun.imageio.plugins.gif.GIFStreamMetadataFormat",
          null, null,
          true,
          GIFImageMetadata.nativeMetadataFormatName,
          "com.sun.imageio.plugins.gif.GIFImageMetadataFormat",
          null, null
          );
}
项目:openjdk-jdk10    文件:PNGImageReader.java   
public InputStream nextElement() {
    try {
        firstTime = false;
        ImageInputStream iis = new SubImageInputStream(stream, length);
        return new InputStreamAdapter(iis);
    } catch (IOException e) {
        return null;
    }
}
项目:openjdk-jdk10    文件:NthItemNodeListTest.java   
public static void main(String[] args) throws IOException {
    // Generate some trivial image and save it to a temporary array
    ByteArrayOutputStream tmp = new ByteArrayOutputStream();
    ImageIO.write(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB),
            "gif", tmp);

    // Read it back in
    ImageInputStream in = new MemoryCacheImageInputStream(
            new ByteArrayInputStream(tmp.toByteArray()));
    ImageReader reader = ImageIO.getImageReaders(in).next();
    reader.setInput(in);

    // Retrieve standard image metadata tree
    IIOMetadata meta = reader.getImageMetadata(0);
    if (meta == null || !meta.isStandardMetadataFormatSupported()) {
        throw new Error("Test failure: Missing metadata");
    }
    Element root = (Element) meta.
            getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);

    NodeList nodeList = root.
            getElementsByTagName(root.getFirstChild().getNodeName());
    /*
     * Accessing the nth node should return null and not throw
     * IndexOutOfBoundsException.
     */
    Node n = (nodeList.item(nodeList.getLength()));
}
项目:VASSAL-src    文件:IOUtilsTest.java   
@Test
public void testCloseQuietlyImageInputStreamOpen() {
  final ImageInputStream in =
    new MemoryCacheImageInputStream(new NullInputStream(1000));

  IOUtils.closeQuietly(in);

  try {
    in.close();
    fail();
  }
  catch (IOException e) {
    // This, oddly, the expected behavior of close().
  }
}