Package java.awt.image.renderable

Examples of java.awt.image.renderable.ParameterBlock


        return mask;
    }

    private BufferedImage getGaussianBlur(int size, BufferedImage image) {
        KernelJAI kernel = Functions.getGaussKernel(size / 3.0);
        ParameterBlock pb = new ParameterBlock();
        pb.addSource(image);
        pb.add(kernel);
        RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                  BorderExtender.createInstance(BorderExtender.BORDER_COPY));
        hints.add(JAIContext.noCacheHint);
        return JAI.create("LCSeparableConvolve", pb, hints).getAsBufferedImage();
    }
View Full Code Here


    static RenderedImage rotate(RenderedImage image, ImageMetadata meta) {
        if (meta != null) {
            ImageOrientation orient = meta.getOrientation();
            TransposeType transpose = orient.getCorrection();
            if (transpose != null) {
                ParameterBlock pb = new ParameterBlock();
                pb.addSource(image);
                pb.add(transpose);
                image = JAI.create(
                    "Transpose", pb, null
                );
            }
        }
View Full Code Here

                break;
            default:
                transpose = null;
        }
        if (transpose != null) {
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add(transpose);
            image = JAI.create(
                "Transpose", pb, null
            );
        }
        return image;
View Full Code Here

            return PlanarImage.wrapRenderedImage(source);

        float scaleX = (float) Math.floor(scale * source.getWidth()) / (float) source.getWidth();
        float scaleY = (float) Math.floor(scale * source.getHeight()) / (float) source.getHeight();

        ParameterBlock params = new ParameterBlock();
        params.addSource(source);
        params.add(AffineTransform.getScaleInstance(scaleX, scaleY));
        params.add(interpolation);
        RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
            BorderExtender.createInstance(BorderExtender.BORDER_COPY));
        return JAI.create("Affine", params, hints);
    }
View Full Code Here

                    samples, colors
                );
                RenderingHints formatHints = new RenderingHints(
                    JAI.KEY_IMAGE_LAYOUT, layout
                );
                ParameterBlock pb = new ParameterBlock();
                pb.addSource(image);
                pb.add(image.getSampleModel().getDataType());
                image = JAI.create("Format", pb, formatHints);
            }
        }
        return image;
    }
View Full Code Here

    // If an image has transparency, then add a bandselect to its pipeline.
    private static RenderedImage maybeBandSelect(RenderedImage image) {
        ColorModel colors = image.getColorModel();
        boolean hasAlpha = colors.hasAlpha();
        if (hasAlpha) {
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            if (image.getColorModel().getNumColorComponents() == 3) {
                pb.add(new int[] {0, 1, 2});
            }
            else {
                pb.add(new int[] {0});
            }
            image = JAI.create("bandselect", pb, null);
        }
        return image;
    }
View Full Code Here

        if(opNode instanceof RenderedOp &&
           name.equalsIgnoreCase("roi")) {
            RenderedOp op = (RenderedOp)opNode;

            ParameterBlock pb = op.getParameterBlock();

            // Retrieve the rendered source image and its ROI.
            PlanarImage src = (PlanarImage)pb.getRenderedSource(0);
            Object property = src.getProperty("ROI");
            if (property == null ||
                property.equals(java.awt.Image.UndefinedProperty) ||
                !(property instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }

            // Return undefined also if source ROI is empty.
            ROI srcROI = (ROI)property;
            if (srcROI.getBounds().isEmpty()) {
                return java.awt.Image.UndefinedProperty;
            }

            /// This should really create a proper AffineTransform
            /// and transform the ROI with it to avoid forcing
            /// ROI.getAsImage to be called.

            // Retrieve the transpose type and create a nearest neighbor
            // Interpolation object.
            TransposeType transposeType =
                (TransposeType)pb.getObjectParameter(0);
            Interpolation interp =
                Interpolation.getInstance(Interpolation.INTERP_NEAREST);

            // Return the transposed ROI.
            return new ROI(JAI.create("transpose", srcROI.getAsImage(),
View Full Code Here

            // which satisfies the description in P. J. Burt and
            // E. H. Adelson, "The Laplacian pyramid as a compact image code",
            // IEEE Transactions on Communications., pp. 532-540, 1983.

            // Add the filtering operation.
            ParameterBlock pb = new ParameterBlock();
            KernelJAI kernel = new KernelJAI(DEFAULT_KERNEL_1D.length,
                                             DEFAULT_KERNEL_1D.length,
                                             DEFAULT_KERNEL_1D.length/2,
                                             DEFAULT_KERNEL_1D.length/2,
                                             DEFAULT_KERNEL_1D,
                                             DEFAULT_KERNEL_1D);
            pb.add(kernel);
            BorderExtender extender =
                BorderExtender.createInstance(BorderExtender.BORDER_COPY);
            RenderingHints hints =
                JAI.getDefaultInstance().getRenderingHints();
            if(hints == null) {
                hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, extender);
            } else {
                hints.put(JAI.KEY_BORDER_EXTENDER, extender);
            }
                                  
            RenderedOp filter = new RenderedOp("convolve", pb, hints);

            // Add the subsampling operation.
            pb = new ParameterBlock();
            pb.addSource(filter);
            pb.add(new Float(0.5F)).add(new Float(0.5F));
            pb.add(new Float(0.0F)).add(new Float(0.0F));
            pb.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
            RenderedOp downSampler = new RenderedOp("scale", pb, null);
            args.set(downSampler, 0);
        }

        // Verify the generic integrity of the arguments and set defaults.
View Full Code Here

  if (op == null)
      throw new IllegalArgumentException(JaiI18N.getString("Generic0"));

        // Get the source Vector from the ParameterBlock.
        ParameterBlock pb = op.getParameterBlock();
  Vector pv = (pb == null) ? null : pb.getSources();

        // If the source Vector is null, replace it by a zero-length
        // Vector. This tricks the DescriptorCache into accepting the
        // parameter and the PropertyEnvironment object created in
        // the DescriptorCache works with either a null or zero-length
View Full Code Here

        if(opNode instanceof RenderedOp &&
           name.equalsIgnoreCase("roi")) {
            RenderedOp op = (RenderedOp)opNode;

            ParameterBlock pb = op.getParameterBlock();

            // Retrieve the rendered source image and its ROI.
            RenderedImage src = (RenderedImage)pb.getRenderedSource(0);
            Object property = src.getProperty("ROI");
            if (property == null ||
                property.equals(java.awt.Image.UndefinedProperty) ||
                !(property instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }
            ROI srcROI = (ROI)property;

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

            // 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(),
                                  src.getWidth() - interp.getWidth() + 1,
                                  src.getHeight() - interp.getHeight() + 1);
            } else {
                srcBounds = new Rectangle(src.getMinX(),
            src.getMinY(),
            src.getWidth(),
            src.getHeight());
            }

            // Set the nearest neighbor interpolation object.
            Interpolation interpNN = interp instanceof InterpolationNearest ?
                interp :
                Interpolation.getInstance(Interpolation.INTERP_NEAREST);

            // Retrieve the operation parameters.
            float sv = pb.getFloatParameter(0);
            EnumeratedParameter shearDir =
                (EnumeratedParameter)pb.getObjectParameter(1);
            float tx = pb.getFloatParameter(2);
            float ty = pb.getFloatParameter(3);

            // Create an equivalent transform.
            AffineTransform transform =
                new AffineTransform(1.0,
                                    shearDir == ShearDescriptor.SHEAR_VERTICAL ? sv : 0,
View Full Code Here

TOP

Related Classes of java.awt.image.renderable.ParameterBlock

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.