Package javax.imageio.stream

Examples of javax.imageio.stream.MemoryCacheImageInputStream$StreamDisposerRecord


  private ImageInputStream createImageInputStream(InputStream is) throws IOException {
    if (this.cacheDir != null) {
      return new FileCacheImageInputStream(is, cacheDir);
    }
    else {
      return new MemoryCacheImageInputStream(is);
    }
  }
View Full Code Here


    try {
      /*
       * ImageIO uses an SPI pattern API. We don't care about the particulars of
       * the implementation, so just choose the first ImageReader.
       */
      MemoryCacheImageInputStream input = new MemoryCacheImageInputStream(
          imageUrl.openStream());
      Iterator<ImageReader> it = ImageIO.getImageReaders(input);
      readers : while (it.hasNext()) {
        ImageReader reader = it.next();
        reader.setInput(input);
View Full Code Here

    getParent().markAsNeedingLayout();
  }

  public void setData(byte[] bytes) throws Exception
  {
    ImageInputStream imageInput = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
    setImage(ImageIO.read(imageInput));
    filename = "[DATA]";

    markAsNeedingLayout();
    getParent().markAsNeedingLayout();
View Full Code Here

      closeMe = false;
      if (ImageIO.getUseCache())
        inStream = new FileCacheImageInputStream((InputStream) input,
            null);
      else
        inStream = new MemoryCacheImageInputStream((InputStream) input);
      // let's mark it
      inStream.mark();
    } else
    // //
    //
View Full Code Here

    @Override
    public ImageInputStream createInputStreamInstance(Object input, boolean useCache, File cacheDir)
        throws IOException {
        if (input instanceof byte[]) {
            return new MemoryCacheImageInputStream(new ByteArrayInputStream((byte[])input));
        }
        return null;
    }
View Full Code Here

        if (truncate)
            length = findBytes(VBYTES, bytes) + 32;

        ImageReader ir = ImageIO.getImageReader(iw);
        ByteArrayInputStream is = new ByteArrayInputStream(bytes, 0, length);
        ImageInputStream iis = new MemoryCacheImageInputStream(is);
        ir.setInput(iis);
        meta = ir.getImageMetadata(0);
        Node node = meta.getAsTree(format);
        for (node = node.getFirstChild();
             !"iTXt".equals(node.getNodeName());
View Full Code Here

            InputStream is = (InputStream)input;

            if (useCache) {
                return new FileCacheImageInputStream(is, cacheDir);
            } else {
                return new MemoryCacheImageInputStream(is);
            }
        } else {
            throw new IllegalArgumentException();
        }
    }
View Full Code Here

  public static String getContentType(byte[] mapObj) throws IOException {

    String type = "";
    ByteArrayInputStream bais = null;
    MemoryCacheImageInputStream mcis = null;
    try {
      bais = new ByteArrayInputStream(mapObj);
      mcis = new MemoryCacheImageInputStream(bais);
      Iterator itr = ImageIO.getImageReaders(mcis);
      while (itr.hasNext()) {
        ImageReader reader = (ImageReader) itr.next();
        if (reader instanceof GIFImageReader) {
          type = "image/gif";
        } else if (reader instanceof JPEGImageReader) {
          type = "image/jpeg";
        } else if (reader instanceof PNGImageReader) {
          type = "image/png";
        } else if (reader instanceof BMPImageReader) {
          type = "application/x-bmp";
        }
      }
    } finally {
      if (bais != null) {
        try {
          bais.close();
        } catch (IOException ioe) {

        }
      }
      if (mcis != null) {
        try {
          mcis.close();
        } catch (IOException ioe) {

        }
      }
    }
View Full Code Here

                }

                // Create a stream.
                ByteArrayInputStream bais =
                    new ByteArrayInputStream(tlmSegments[itlm]);
                ImageInputStream iis = new MemoryCacheImageInputStream(bais);

                try {
                    int Stlm = iis.read();
                    int ST = (Stlm >> 4) & 0x3;
                    int SP = (Stlm >> 6) & 0x1;

                    int tlmLength = tlmSegments[itlm].length;
                    while(iis.getStreamPosition() < tlmLength) {
                        int tileIndex = tileCounter;
                        switch(ST) {
                        case 1:
                            tileIndex = iis.read();
                            break;
                        case 2:
                            tileIndex = iis.readUnsignedShort();
                        }

                        if(tlmOffsets[tileIndex] == null) {
                            tlmOffsets[tileIndex] = new ArrayList();
                        }
                        tlmOffsets[tileIndex].add(new Long(tilePos));

                        long tileLength = 0L;
                        switch(SP) {
                        case 0:
                            tileLength = iis.readUnsignedShort();
                            break;
                        case 1:
                            tileLength = iis.readUnsignedInt();
                            break;
                        }

                        tilePos += tileLength;
View Full Code Here

            buf[bufOffset++] = (byte)0xff; // Marker identifier
            buf[bufOffset++] = (byte)EOI;

            ByteArrayInputStream bais =
                new ByteArrayInputStream(buf, 0, bufOffset);
            ImageInputStream is = new MemoryCacheImageInputStream(bais);

            JPEGReader.setInput(is, true, true);
        }

        // Read real image
View Full Code Here

TOP

Related Classes of javax.imageio.stream.MemoryCacheImageInputStream$StreamDisposerRecord

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.