Package javax.imageio.stream

Examples of javax.imageio.stream.MemoryCacheImageInputStream$StreamDisposerRecord


        // read bit stream
        ImageInputStream iis = null;
        try
        {
            // create stream
            iis = new MemoryCacheImageInputStream(pdImage.getStream().createInputStream());
            final float sampleMax = (float)Math.pow(2, bitsPerComponent) - 1f;
            final boolean isIndexed = colorSpace instanceof PDIndexed;

            // init color key mask
            float[] colorKeyRanges = null;
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

                {
                // 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

        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

    command = new CaptureScreenshotToStringCommand();
    String returnValue = command.execute();
    String result = returnValue.split(",")[0];
    String image = returnValue.split(",")[1];
    assertEquals("OK", result);
    assertNotNull(ImageIO.read(new MemoryCacheImageInputStream(
        new ByteArrayInputStream(Base64.decode(image)))));

  }
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

        this.closer = close;
        if (useFile) {
            delegatee = new FileCacheImageInputStream(
                is, new File(System.getProperty(TMP_DIR_PROPERTY_KEY)));
        } else {
            delegatee = new MemoryCacheImageInputStream(is);
        }
    }
View Full Code Here

     * @param file the file to obtain the stream from
     * @throws IOException
     */
    public DefaultSeekableInputStream(File file) throws IOException {
        this.closer = null;
        this.delegatee = new MemoryCacheImageInputStream(new FileInputStream(file));
    }
View Full Code Here

    public void decode(InputStream compressedData, OutputStream result, COSDictionary options, int filterIndex)
            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.