Package javax.imageio.stream

Examples of javax.imageio.stream.MemoryCacheImageInputStream$StreamDisposerRecord


      Iterator<ImageReader> readers = ImageIO.getImageReadersByMIMEType("image/jpeg2000");
      if (readers.hasNext() == false) {
        throw new PDFParseException("JPXDecode failed. No reader available");
      }
      ImageReader reader = readers.next();
      reader.setInput(new MemoryCacheImageInputStream(new ByteArrayInputStream(input)));
      BufferedImage bimg = reader.read(0);
      return bimg;
    } catch (IOException e) {
            throw new PDFParseException("JPXDecode failed", e);
    }
View Full Code Here


        ArrayList<ShadedTriangle> list = new ArrayList<ShadedTriangle>();
        long maxSrcCoord = (long) Math.pow(2, bitsPerCoordinate) - 1;
        long maxSrcColor = (long) Math.pow(2, bitsPerColorComponent) - 1;
        COSStream cosStream = (COSStream) cosDictionary;

        ImageInputStream mciis = new MemoryCacheImageInputStream(cosStream.getUnfilteredStream());
        byte flag = (byte) 0;

        try
        {
            flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
        }
        catch (EOFException ex)
        {
            LOG.error(ex);
        }

        while (true)
        {
            Vertex p0, p1, p2;
            Point2D[] ps;
            float[][] cs;
            int lastIndex;
            try
            {
                switch (flag)
                {
                    case 0:
                        p0 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
                        flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
                        if (flag != 0)
                        {
                            LOG.error("bad triangle: " + flag);
                        }
                        p1 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
                        mciis.readBits(bitsPerFlag);
                        if (flag != 0)
                        {
                            LOG.error("bad triangle: " + flag);
                        }
                        p2 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
                        ps = new Point2D[]
                        {
                            p0.point, p1.point, p2.point
                        };
                        cs = new float[][]
                        {
                            p0.color, p1.color, p2.color
                        };
                        list.add(new ShadedTriangle(ps, cs));
                        flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
                        break;
                    case 1:
                        lastIndex = list.size() - 1;
                        if (lastIndex < 0)
                        {
                            LOG.error("broken data stream: " + list.size());
                        }
                        else
                        {
                            ShadedTriangle preTri = list.get(lastIndex);
                            p2 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
                            ps = new Point2D[]
                            {
                                preTri.corner[1], preTri.corner[2], p2.point
                            };
                            cs = new float[][]
                            {
                                preTri.color[1], preTri.color[2], p2.color
                            };
                            list.add(new ShadedTriangle(ps, cs));
                            flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
                        }
                        break;
                    case 2:
                        lastIndex = list.size() - 1;
                        if (lastIndex < 0)
                        {
                            LOG.error("broken data stream: " + list.size());
                        }
                        else
                        {
                            ShadedTriangle preTri = list.get(lastIndex);
                            p2 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
                            ps = new Point2D[]
                            {
                                preTri.corner[0], preTri.corner[2], p2.point
                            };
                            cs = new float[][]
                            {
                                preTri.color[0], preTri.color[2], p2.color
                            };
                            list.add(new ShadedTriangle(ps, cs));
                            flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
                        }
                        break;
                    default:
                        LOG.warn("bad flag: " + flag);
                        break;
                }
            }
            catch (EOFException ex)
            {
                break;
            }
        }
        mciis.close();
        return list;
    }
View Full Code Here

        ArrayList<Patch> list = new ArrayList<Patch>();
        long maxSrcCoord = (long) Math.pow(2, bitsPerCoordinate) - 1;
        long maxSrcColor = (long) Math.pow(2, bitsPerColorComponent) - 1;
        COSStream cosStream = (COSStream) cosDictionary;

        ImageInputStream mciis = new MemoryCacheImageInputStream(cosStream.getUnfilteredStream());

        Point2D[] implicitEdge = new Point2D[4];
        float[][] implicitCornerColor = new float[2][numberOfColorComponents];

        byte flag = (byte) 0;

        try
        {
            flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
        }
        catch (EOFException ex)
        {
            LOG.error(ex);
        }

        while (true)
        {
            try
            {
                boolean isFree = (flag == 0);
                Patch current = readPatch(mciis, isFree, implicitEdge, implicitCornerColor,
                        maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform, numP);
                if (current == null)
                {
                    break;
                }
                list.add((Patch) current);
                flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
                switch (flag)
                {
                    case 0:
                        break;
                    case 1:
                        implicitEdge = current.getFlag1Edge();
                        implicitCornerColor = current.getFlag1Color();
                        break;
                    case 2:
                        implicitEdge = current.getFlag2Edge();
                        implicitCornerColor = current.getFlag2Color();
                        break;
                    case 3:
                        implicitEdge = current.getFlag3Edge();
                        implicitCornerColor = current.getFlag3Color();
                        break;
                    default:
                        LOG.warn("bad flag: " + flag);
                        break;
                }
            }
            catch (EOFException ex)
            {
                break;
            }
        }
        mciis.close();
        return list;
    }
View Full Code Here

                {
                // PDF spec 1.7 p.171:
                // Each sample value is represented as a sequence of BitsPerSample bits.
                // Successive values are adjacent in the bit stream;
                // there is no padding at byte boundaries.
                ImageInputStream mciis = new MemoryCacheImageInputStream(getPDStream().createInputStream());
                for (int i = 0; i < arraySize; i++)
                {
                    for (int k = 0; k < numberOfOutputValues; k++)
                    {
                        // TODO will this cast work properly for 32 bitsPerSample or should we use long[]?
                        samples[index][k] = (int) mciis.readBits(bitsPerSample);
                    }
                    index++;
                }
                mciis.close();
            }
            catch (IOException exception)
            {
                LOG.error("IOException while reading the sample values of this function.", exception);
            }
View Full Code Here

   */
  private static BufferedImage load(final String filename)
  {
    try
    {
      return ImageIO.read(new MemoryCacheImageInputStream(
        KittenCaptchaPanel.class.getResourceAsStream(filename)));
    }
    catch (IOException e)
    {
      e.printStackTrace();
View Full Code Here

     */
    private BufferedImage load(final String filename)
    {
      try
      {
        final BufferedImage loadedImage = ImageIO.read(new MemoryCacheImageInputStream(
          KittenCaptchaPanel.class.getResourceAsStream(filename + ".png")));
        final BufferedImage image = new BufferedImage(loadedImage.getWidth(),
          loadedImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
        final Graphics2D graphics = image.createGraphics();
        graphics.drawImage(loadedImage, 0, 0, null);
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();
View Full Code Here

   */
  private static BufferedImage load(final String filename)
  {
    try
    {
      return ImageIO.read(new MemoryCacheImageInputStream(
        KittenCaptchaPanel.class.getResourceAsStream(filename)));
    }
    catch (IOException e)
    {
      e.printStackTrace();
View Full Code Here

     */
    private BufferedImage load(final String filename)
    {
      try
      {
        final BufferedImage loadedImage = ImageIO.read(new MemoryCacheImageInputStream(
          KittenCaptchaPanel.class.getResourceAsStream(filename + ".png")));
        final BufferedImage image = new BufferedImage(loadedImage.getWidth(),
          loadedImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
        final Graphics2D graphics = image.createGraphics();
        graphics.drawImage(loadedImage, 0, 0, null);
View Full Code Here

    private void doLZWDecode(InputStream compressedData, OutputStream result) throws IOException
    {
        ArrayList<byte[]> codeTable = null;
        int chunk = 9;
        MemoryCacheImageInputStream in = new MemoryCacheImageInputStream(compressedData);
        long nextCommand = 0;
        long prevCommand = -1;

        try
        {
            while ((nextCommand = in.readBits(chunk)) != EOD)
            {
                if (nextCommand == CLEAR_TABLE)
                {
                    chunk = 9;
                    codeTable = createCodeTable();
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.