Package javax.media.jai

Examples of javax.media.jai.PlanarImage


    @Override
    public Object clone() throws CloneNotSupportedException {
        int numOfImages = images.length;
        BufferedImage[] imgs = new BufferedImage[numOfImages];
        for (int i = 0; i < numOfImages; i++) {
            PlanarImage oldImg = getAsPlanarImage(i);
            imgs[i] = oldImg.getAsBufferedImage();
        }

        ImageWrapper newImgWrapper = new ImageWrapper(imgs);
        newImgWrapper.quality = quality;
        newImgWrapper.broken = broken;
View Full Code Here


            new IntegerSequence(destMinY, destMaxY);
        ySplits.insert(destMinY);
        ySplits.insert(destMaxY);

        // Overlay the forward-mapped source tile grid
        PlanarImage src = getSource(0);
        int sMinX = src.getMinX();
        int sMinY = src.getMinY();
        int sWidth = src.getWidth();
        int sHeight = src.getHeight();
        int sMaxX = sMinX + sWidth - 1;
        int sMaxY = sMinY + sHeight - 1;
        int sTileWidth = src.getTileWidth();
        int sTileHeight = src.getTileHeight();
        int sTileGridXOffset = src.getTileGridXOffset();
        int sTileGridYOffset = src.getTileGridYOffset();

        int xStart = 0;
        int xGap = 0;
        int yStart = 0;
        int yGap = 0;

        // Insert splits from source image.
        //
        // We can think of the splits as forming an infinite sequence
        // xStart + kx*xGap, yStart + ky*yGap, where kx and ky range
        // over all integers, negative and positive.

        // Forward map the source tile grid origin Note that in cases
        // where an axis is "flipped" an adjustment must be made.  For
        // example, consider flipping an image horizontally.
        // If the image has a tile X origin of 0, a tile width
        // of 50, and a total width of 100, then forward mapping the
        // points (0, 0) and (50, 0) yields the points (99, 0) and
        // (49, 0).  In the original image, the tile split lines lay
        // to the left of the pixel; in the flipped image, they lie
        // to the right of the forward mapped pixels.  Thus 1 must
        // be added to the forward mapped pixel position to get the
        // correct split location.
        int[] pt = new int[2];
        pt[0] = sTileGridXOffset;
        pt[1] = sTileGridYOffset;
        mapPoint(pt, sMinX, sMinY, sMaxX, sMaxY, type, true);
        xStart = pt[0];
        yStart = pt[1];

        // Forward map the input tile size
        switch (type) {
        case 0: // FLIP_VERTICAL
            ++yStart;
            xGap = sTileWidth;
            yGap = sTileHeight;
            break;

        case 1: // FLIP_HORIZONTAL
            ++xStart;
            xGap = sTileWidth;
            yGap = sTileHeight;
            break;

        case 2: // FLIP_DIAGONAL
            xGap = sTileHeight;
            yGap = sTileWidth;
            break;

        case 3: // FLIP_ANTIDIAGONAL
            ++xStart;
            ++yStart;
            xGap = sTileHeight;
            yGap = sTileWidth;
            break;

        case 4: // ROTATE_90
            ++xStart;
            xGap = sTileHeight;
            yGap = sTileWidth;
            break;

        case 5: // ROTATE_180
            ++xStart;
            ++yStart;
            xGap = sTileWidth;
            yGap = sTileHeight;
            break;

        case 6: // ROTATE_270
            ++yStart;
            xGap = sTileHeight;
            yGap = sTileWidth;
            break;
        }

        // Now we identify the source splits that intersect
        // the destination rectangle and merge them in.
        int kx = (int)Math.floor((double)(destMinX - xStart)/xGap);
        int xSplit = xStart + kx*xGap;
        while (xSplit < destMaxX) {
            xSplits.insert(xSplit);
            xSplit += xGap;
        }

        int ky = (int)Math.floor((double)(destMinY - yStart)/yGap);
        int ySplit = yStart + ky*yGap;
        while (ySplit < destMaxY) {
            ySplits.insert(ySplit);
            ySplit += yGap;
        }

        // Allocate memory for source Rasters.
        Raster[] sources = new Raster[1];

        //
        // Divide destRect into sub rectangles based on the source
        // splits, and compute each sub rectangle separately.
        //
        int x1, x2, y1, y2, w, h;
        Rectangle subRect = new Rectangle();

        ySplits.startEnumeration();
        for (y1 = ySplits.nextElement(); ySplits.hasMoreElements(); y1 = y2) {
            y2 = ySplits.nextElement();
            h = y2 - y1;

            xSplits.startEnumeration();
            for (x1 = xSplits.nextElement();
                 xSplits.hasMoreElements(); x1 = x2) {
                x2 = xSplits.nextElement();
                w = x2 - x1;

                // Get sources

                // Backwards map the starting destination point
                pt[0] = x1;
                pt[1] = y1;
                mapPoint(pt, sMinX, sMinY, sMaxX, sMaxY, type, false);

                // Determine the source tile involved
                int tx = src.XToTileX(pt[0]);
                int ty = src.YToTileY(pt[1]);
                sources[0] = src.getTile(tx, ty);

                subRect.x = x1;
                subRect.y = y1;
                subRect.width = w;
                subRect.height = h;
View Full Code Here

        Raster src = sources[0];

        //
        // Get the minX, minY, width & height of sources raster
        //
        PlanarImage source = getSource(0);
        int sMinX = source.getMinX();
        int sMinY = source.getMinY();
        int sWidth = source.getWidth();
        int sHeight = source.getHeight();
        int sMaxX = sMinX + sWidth - 1;
        int sMaxY = sMinY + sHeight - 1;

        int translateX = src.getSampleModelTranslateX();
        int translateY = src.getSampleModelTranslateY();
View Full Code Here

        ImageWrapper wi = rr.render();
        BufferedImage bi = wi.getAsBufferedImage();
       
        for (int i = 0; i < times; i++) {     
            start = System.currentTimeMillis();
            PlanarImage zoomOp = scaler.doScale(PlanarImage.wrapRenderedImage(bi), scale);
            zoomOp.getAsBufferedImage();
            end = System.currentTimeMillis();
            total += (end - start);
        }

        System.out.printf("Scale alg : %s \n", scaler.getName());
View Full Code Here

        /*
         * (non-Javadoc)
         * @see com.alibaba.simpleimage.ScaleSpeedTest.Scaler#doScale(javax.media .jai.PlanarImage, float)
         */
        public PlanarImage doScale(PlanarImage in, float scale) {
            PlanarImage zoomOp = new SubsampleAverageOpImage(in, null, null, (double) scale, (double) scale);

            return zoomOp;
        }
View Full Code Here

            WriteRender wr = null;
            try {
                ReadRender rr = new ReadRender(in, true);

                ImageWrapper wi = rr.render();
                PlanarImage img = wi.getAsPlanarImage();
                if ("progbicu".equalsIgnoreCase(name)) {
                    img = doProgressiveBicubic(img);
                } else if ("Nearest".equalsIgnoreCase(name)) {
                    img = doScaleNearest(img);
                } else if ("Bilinear".equalsIgnoreCase(name)) {
View Full Code Here

            // Retrieve the Interpolation object.
            Interpolation interp = (Interpolation)pb.getObjectParameter(3);

            // Determine the effective source bounds.
            Rectangle srcBounds = null;
            PlanarImage dst = op.getRendering();
            if (dst instanceof GeometricOpImage &&
                ((GeometricOpImage)dst).getBorderExtender() == null) {
                srcBounds =
                    new Rectangle(src.getMinX() + interp.getLeftPadding(),
                                  src.getMinY() + interp.getTopPadding(),
View Full Code Here

               evtSrc instanceof RenderedImage &&
               propName.equals("invalidregion"))) &&
             nodeSources.contains(evtSrc)))) {

            // Save the previous rendering.
            PlanarImage theOldImage = theImage;

            // Initialize the event flag.
            boolean shouldFireEvent = false;

            // Set default invalid region to null (the entire image).
View Full Code Here

                ImageLayout il = new ImageLayout();
                il.setSampleModel(ti.getSampleModel());
                RenderingHints rh = new RenderingHints(JAI.KEY_IMAGE_LAYOUT,
                                                       il);

                PlanarImage constImage = JAI.create("constant", pb, rh);

                // Compute a complement ROI.
                ROI complementROI =
                    (new ROIShape(ti.getBounds())).subtract(roi);;

                // Fill the background.
                int maxTileY = ti.getMaxTileY();
                int maxTileX = ti.getMaxTileX();
                for(int j = ti.getMinTileY(); j <= maxTileY; j++) {
                    for(int i = ti.getMinTileX(); i <= maxTileX; i++) {
                        if(!roi.intersects(ti.getTileRect(i, j))) {
                            ti.setData(constImage.getTile(i, j),
                                       complementROI);
                        }
                    }
                }
View Full Code Here

        // Get the default registry.
        OperationRegistry registry = (renderHints == null) ? null :
      (OperationRegistry)renderHints.get(JAI.KEY_OPERATION_REGISTRY);

        PlanarImage im = new FileStoreImage(RIFRegistry.create
          (registry, "encode", pb, renderHints), stream);

        return im;
    }
View Full Code Here

TOP

Related Classes of javax.media.jai.PlanarImage

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.