Package javax.imageio

Examples of javax.imageio.ImageReader


        }

        private JComponent makeStore(File image, final String key, String mime, Map<String, Serializable> attrs) throws IOException {
                String m = _getImageMimeType(image, "r");
                Sprite picture = null;
                ImageReader r = null;
                try {
                        Map<String, Object> s = Sprite._loadImage(image, false, m, Sprite.MODE_JAVA2D | Sprite.MODE_TILE, _getBufferedType(m), false);
                        r = (ImageReader) s.get("reader");
                        picture = new Sprite(image, m, new Dimension(r.getWidth(0), r.getHeight(0)), true);
                } catch (Exception ex) {
                        if (JXAenvUtils._debug) {
                                ex.printStackTrace();
                        }
                        IOException e = new IOException(ex.getMessage());
                        e.initCause(ex);
                        throw e;
                } finally {
                        ((ImageInputStream) r.getInput()).flush();
                        r.dispose();
                        ((ImageInputStream) r.getInput()).close();
                        picture.setStoreMode(Sprite.MODE_JAVA2D | Sprite.MODE_TILE);
                        return makeStore(picture, key, mime, attrs);
                }

        }
View Full Code Here


     * reader (user's savvy), default 0
     * @param mime the mime-type to look for
     * @return the ImageReader that fits the mime-type
     */
    protected static ImageReader _getReader(int n, String mime) {
        ImageReader r = null;
        IIOReadProgressAdapter rpl = new IIOReadProgressAdapter(DebugMap._getInstance().isDebuggerEnabled(Sprite.class) && DebugMap._getInstance().isDebugLevelEnabled(DebugMap._getInstance()._VOID));
        IIOReadWarningAdapter rwl = new IIOReadWarningAdapter(DebugMap._getInstance().isDebuggerEnabled(Sprite.class));
        int i = 0;
        for (Iterator readers = ImageIO.getImageReadersByMIMEType(mime); readers.hasNext(); i++) {
            r = (ImageReader) readers.next();
            if (i != n) {
                continue;
            }
            r.addIIOReadProgressListener(rpl);
            r.addIIOReadWarningListener(rwl);
            if (i == n) {
                return r;
            }
            i++;
        }
View Full Code Here

     * @param n reader index in ImageIO
     * @return ImageReader instance
     * @see #mime
     */
    protected ImageReader getReader(int n, String mime) {
        ImageReader r = _getReader(n, mime);
        if (r == null) {
            return null;
        }
        synchronized (rProgList) {
            for (Iterator<IIOReadProgressListener> it = rProgList.iterator(); it.hasNext();) {
                r.addIIOReadProgressListener(it.next());
            }
        }
        synchronized (rWarnList) {
            for (Iterator<IIOReadWarningListener> it = rWarnList.iterator(); it.hasNext();) {
                r.addIIOReadWarningListener(it.next());
            }
        }
        return r;
    }
View Full Code Here

                String baseCodeStr = rb.getString("GFX_BASE_CODE_TILES_MAP");
                _cacheManager.setListCapacity(Integer.parseInt(rb.getString("GFX_BASE_CODE")));
                try {
                    Sprite spTiles = new Sprite(rb.getString("GFX_BASE_CODE_TILES"), true, "image/x-png", _rbGetDim("GFX_BASE_CODE_TILES").ROI.getSize(), true);
                    spTiles.setTileModeEnabled(true);
                    ImageReader r = spTiles.getTileReader(true);
                    ImageReadParam irp = spTiles.getTileReaderParams(r);
                    int n = 0;
                    try {
                        for (String tile : baseCodeStr.split(" ")) {
                            irp.setSourceRegion(new Rectangle((int) ((float) r.getWidth(0) / (float) Integer.parseInt(rb.getString("GFX_BASE_CODE")) * (float) n), 0, (int) ((float) r.getWidth(0) / (float) Integer.parseInt(rb.getString("GFX_BASE_CODE"))), r.getHeight(0)));
                            BufferedImage tileImg = r.read(0, irp);
                            Sprite sp = new Sprite(tileImg, "image/x-png", baseCodeDim = new Dimension(tileImg.getWidth(), tileImg.getHeight()));
                            sp.setStoreMode(Sprite.MODE_TEXTURE);
                            _cacheSyncManager.put(tile, sp);
                            _cacheHashRegistry.put(tile, sp.hashCode());
                            n++;
                        }
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    } finally {
                        r.dispose();
                        spTiles.clearResource();
                        Sprite grid = new Sprite();
                        grid.setSize(100, 100);
                        grid.clearImageGraphics();
                        grid.runValidate();
View Full Code Here

        } else if (src instanceof URL) {
            bi = ImageIO.read((URL) src);
        } else if (src instanceof InputStream) {
            bi = ImageIO.read((InputStream) src);
        } else if (src instanceof ImageReader) {
            ImageReader r = ((ImageReader) src);
            bi = r.read(0, r.getDefaultReadParam());
            SpriteIO._mt.addImage(bi, 0);
            SpriteIO._mt.waitForID(0);
            SpriteIO._mt.removeImage(bi);
            r.dispose();
        } else {
            throw new JXAException("src is not one of the supported class.");
        }
        Sprite sp = null;
        boolean flushSp = false;
View Full Code Here

      if (!iter.hasNext())
      {
         return;
      }

      ImageReader reader = (ImageReader) iter.next();
      ImageReadParam param = reader.getDefaultReadParam();
      reader.setInput(stream, true, true);
      String type = reader.getFormatName();
      setContentType(Type.getTypeByFormatName(type));
      bufferedImage = reader.read(0, param);
      stream.close();
      reader.dispose();
      dirty = true;
      inputStream.close();
   }
View Full Code Here

    Assert.notNull(inputStream, "inputStream");
    ImageInputStream imageInputStream = ImageIO.createImageInputStream(inputStream);
    Iterator<ImageReader> readers = ImageIO.getImageReaders(imageInputStream);

    if (readers.hasNext()) {
      ImageReader reader = null;

      while (readers.hasNext()) {
        ImageReader tmp = readers.next();
        if (JAIExifReader.JPEG_METADATA_FORMAT.equals(tmp.getOriginatingProvider().getNativeImageMetadataFormatName())) {
          reader = tmp;
          break;
        }
      }
View Full Code Here

  }

  private IIOMetadata getEXIFMetadata(final byte[] bytes) throws IOException {
    Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName(ImageType.TIFF.name().toLowerCase());
    if (readers.hasNext()) {
      ImageReader reader = readers.next();
      ImageInputStream wrapper = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes, JAIExifReader.SEEK_BYTES, bytes.length - JAIExifReader.SEEK_BYTES));
      reader.setInput(wrapper, true, false);

      IIOMetadata metadata = reader.getImageMetadata(0);

      reader.dispose();

      return metadata;
    }

    return null;
View Full Code Here

    public Object getContent(DataSource ds) throws IOException {
        Iterator i = ImageIO.getImageReadersByMIMEType(ds.getContentType());
        if (!i.hasNext()) {
            throw new UnsupportedDataTypeException();
        }
        ImageReader reader = (ImageReader) i.next();
        return reader.read(0);
    }
View Full Code Here

        in.delete();
    }
   
    private void checkType(File file, String type) throws IOException {
        ImageInputStream iis = ImageIO.createImageInputStream(file);
        ImageReader reader = ImageIO.getImageReaders(iis).next();
        String format = reader.getFormatName();
        assertEquals(type, format.toUpperCase());
    }
View Full Code Here

TOP

Related Classes of javax.imageio.ImageReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.