Package javax.imageio.stream

Examples of javax.imageio.stream.MemoryCacheImageInputStream$StreamDisposerRecord


        //TODO missing: BBox, AntiAlias (p. 305 in 1.7 spec)
       
        // p318:
        //  reading in sequence from higher-order to lower-order bit positions
        ImageInputStream mciis = new MemoryCacheImageInputStream(cosStream.getUnfilteredStream());

        int verticesPerRow = shadingType5.getVerticesPerRow(); //TODO check >=2
        LOG.debug("verticesPerRow" + verticesPerRow);

        try
        {
            ArrayList<Vertex> prevVertexRow = new ArrayList<Vertex>();
            while (true)
            {
                // read a vertex row
                ArrayList<Vertex> vertexList = new ArrayList<Vertex>();
                for (int row = 0; row < verticesPerRow; ++row)
                {
                    vertexList.add(readVertex(mciis, (byte) 0, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRangeTab));
                }
                transformVertices(vertexList, ctm, xform, pageHeight);

                // create the triangles from two rows
                if (!prevVertexRow.isEmpty())
                {
                    for (int vj = 0; vj < vertexList.size() - 1; ++vj)
                    {
                        // p.192,194 pdf spec 1.7
                        Vertex vij = prevVertexRow.get(vj); // v i,j
                        Vertex vijplus1 = prevVertexRow.get(vj + 1); // v i,j+1
                        Vertex viplus1j = vertexList.get(vj); // v i+1,j
                        Vertex viplus1jplus1 = vertexList.get(vj + 1); // v i+1,j+1
                        GouraudTriangle g = new GouraudTriangle(vij.point, vij.color,
                                vijplus1.point, vijplus1.color,
                                viplus1j.point, viplus1j.color);
                        if (!g.isEmpty())
                        {
                            triangleList.add(g);
                        }
                        else
                        {
                            LOG.debug("triangle is empty!");
                        }
                        g = new GouraudTriangle(vijplus1.point, vijplus1.color,
                                viplus1j.point, viplus1j.color,
                                viplus1jplus1.point, viplus1jplus1.color);
                        if (!g.isEmpty())
                        {
                            triangleList.add(g);
                        }
                        else
                        {
                            LOG.debug("triangle is empty!");
                        }
                    }
                }
                prevVertexRow = vertexList;
            }
        }
        catch (EOFException ex)
        {
            LOG.debug("EOF");
        }

        mciis.close();
    }
View Full Code Here


        }

        //TODO missing: BBox, AntiAlias (p. 305 in 1.7 spec)
        // p318:
        //  reading in sequence from higher-order to lower-order bit positions
        ImageInputStream mciis = new MemoryCacheImageInputStream(cosStream.getUnfilteredStream());
        while (true)
        {
            try
            {
                byte flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
                LOG.debug("flag: " + flag);
                switch (flag)
                {
                    case 0:
                        Vertex v1 = readVertex(mciis, flag, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRangeTab);
                        Vertex v2 = readVertex(mciis, (byte) mciis.readBits(bitsPerFlag), maxSrcCoord, maxSrcColor,
                                rangeX, rangeY, colRangeTab);
                        Vertex v3 = readVertex(mciis, (byte) mciis.readBits(bitsPerFlag), maxSrcCoord, maxSrcColor,
                                rangeX, rangeY, colRangeTab);

                        // add them after they're read, so that they are never added if there is a premature EOF
                        vertexList.add(v1);
                        vertexList.add(v2);
                        vertexList.add(v3);
                        break;
                    case 1:
                    case 2:
                        vertexList.add(readVertex(mciis, flag, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRangeTab));
                        break;
                    default:
                        LOG.warn("bad flag: " + flag);
                        break;
                }
            }
            catch (EOFException ex)
            {
                LOG.debug("EOF");
                if (vertexList.size() < 3)
                {
                    LOG.warn("Incomplete mesh is ignored");
                    vertexList.clear();
                }
                else if (vertexList.size() > 1 && vertexList.get(0).flag != 0)
                {
                    LOG.warn("Mesh with incorrect start flag " + vertexList.get(0).flag + " is ignored");
                    vertexList.clear();
                }
                // check that there are 3 entries if there is a 0 flag
                int vi = 0;
                while (vi < vertexList.size())
                {
                    if (vertexList.get(vi).flag == 0)
                    {
                        if (vi + 2 >= vertexList.size())
                        {
                            LOG.warn("Mesh with incomplete triangle");
                            // remove rest
                            while (vertexList.size() >= vi + 1)
                            {
                                vertexList.remove(vi);
                            }
                            break;
                        }
                        vi += 3;
                    }
                    else
                    {
                        ++vi;
                    }
                }
                break;
            }
        }
        mciis.close();
        transformVertices(vertexList, ctm, xform, pageHeight);
        createTriangleList(vertexList);
    }
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

    private void doLZWDecode(InputStream compressedData, OutputStream result, int earlyChange) 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

        ArrayList<Vertex> vlist = new ArrayList<Vertex>();
        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());
        while (true)
        {
            Vertex p;
            try
            {
View Full Code Here

  static Dimension getDimension(byte[] image, String MIMEType) {
    if ("image/pjpeg".equals(MIMEType)) {
      MIMEType = "image/jpeg";
    }
    // a more eficient way than caching a BatyArrayInputStream would be nice
    ImageInputStream iis = new MemoryCacheImageInputStream(
        new ByteArrayInputStream(image));
    Iterator readerIter = ImageIO.getImageReadersByMIMEType(MIMEType);
    while (readerIter.hasNext()) {
      ImageReader currentReader = (ImageReader) readerIter.next();
      currentReader.setInput(iis);
      Dimension result = new Dimension();
      try {
        result.width = currentReader.getWidth(0);
        result.height = currentReader.getHeight(0);
        iis.close();
      } catch (IOException ex) {
        log.warn("IOException", ex);
      }
      currentReader.dispose();
      return result;
View Full Code Here

    MediaType contentType = MediaType.IMAGE_JPEG;
    Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(contentType.toString());
    if (imageReaders.hasNext()) {
      ImageReader imageReader = imageReaders.next();
      ImageReadParam irp = imageReader.getDefaultReadParam();
      imageReader.setInput(new MemoryCacheImageInputStream(photo), true);
      body = imageReader.read(0, irp);
    } else {
      throw new HttpMessageNotReadableException("Could not find javax.imageio.ImageReader for Content-Type ["
          + contentType + "]");
    }
View Full Code Here

    MediaType contentType = MediaType.IMAGE_JPEG;
    Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(contentType.toString());
    if (imageReaders.hasNext()) {
      ImageReader imageReader = imageReaders.next();
      ImageReadParam irp = imageReader.getDefaultReadParam();
      imageReader.setInput(new MemoryCacheImageInputStream(photo), true);
      body = imageReader.read(0, irp);
    } else {
      throw new HttpMessageNotReadableException("Could not find javax.imageio.ImageReader for Content-Type ["
          + contentType + "]");
    }
View Full Code Here

    MediaType contentType = MediaType.IMAGE_JPEG;
    Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(contentType.toString());
    if (imageReaders.hasNext()) {
      ImageReader imageReader = imageReaders.next();
      ImageReadParam irp = imageReader.getDefaultReadParam();
      imageReader.setInput(new MemoryCacheImageInputStream(photo), true);
      body = imageReader.read(0, irp);
    } else {
      throw new HttpMessageNotReadableException("Could not find javax.imageio.ImageReader for Content-Type ["
          + contentType + "]");
    }
View Full Code Here

                // We're getting bigger and bigger thumbnails, so they should have more bytes
                // than the previous ones.
                assertTrue(data.length > prevSize);

                reader.setInput(new MemoryCacheImageInputStream(new ByteArrayInputStream(data)));
                int w = reader.getWidth(0);
                int h = reader.getHeight(0);
                int expectedW = Math.min(size.width, origW);
                int expectedH = Math.min(size.width, origH);
                assertTrue((w == expectedW && h <= expectedH) || (h == expectedH && w <= expectedW),
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.