/** * Gets the bounding box for the output of <code>ScaleOpImage</code>. * This method satisfies the implementation of CRIF. */ public Rectangle2D getBounds2D(ParameterBlock paramBlock) { RenderableImage source = paramBlock.getRenderableSource(0); double scaleX = paramBlock.getDoubleParameter(0); double scaleY = paramBlock.getDoubleParameter(1); // Get the source dimensions float x0 = (float)source.getMinX(); float y0 = (float)source.getMinY() ; float w = (float)source.getWidth(); float h = (float)source.getHeight(); // Forward map the source using x0, y0, w and h float d_x0 = (float)(x0 * scaleX); float d_y0 = (float)(y0 * scaleY); float d_w = (float)(w * scaleX); float d_h = (float)(h * scaleY); return new Rectangle2D.Float(d_x0, d_y0, d_w, d_h); }
/** * Validates the input parameter. * * <p> In addition to the standard checks performed by the * superclass method, this method checks that the length of the * "constants" array is at least 1. */ protected boolean validateParameters(ParameterBlock args, StringBuffer message) { if (!super.validateParameters(args, message)) { return false; } int length = ((double[])args.getObjectParameter(0)).length; if (length < 1) { message.append(getName() + " " + JaiI18N.getString("MultiplyConstDescriptor2")); return false; } return true; }
private PlanarImage convertColorModel(PlanarImage pi) { int numComponents = pi.getColorModel().getNumComponents(); boolean isGrey = numComponents == 1; ColorModel colorModel = rgbColorModel; if (isGrey) colorModel = grayColorModel; try { ParameterBlock pb = new ParameterBlock(); pb.addSource(pi).add(colorModel); RenderedOp dst = JAI.create("ColorConvert", pb); return dst.getRendering(); } catch (IllegalArgumentException ex) { logger.info("Error: Cannot convert color model. Original color model: " + pi.getColorModel()); return null; } }
public static PlanarImage adjustBrightness(PlanarImage src, final double b) { final double[][] matrixRGB = { {1d, 0D, 0D, b}, {0D, 1d, 0D, b}, {0, 0D, 1d, b} }; final double[][] matrixGrey = { {1d, b} }; double[][] matrix; if (src.getSampleModel().getNumBands() > 1) matrix = matrixRGB; else matrix = matrixGrey; ParameterBlock pb = new ParameterBlock(); pb.addSource(src); pb.add(matrix); return JAI.create("bandcombine", pb); }
private static void graphicFillLineString(final LineSymbolizer symbolizer, final Shape shape, final Image image, final float size, final double opacity) { Double width = new Double(Math.max(1, shape.getBounds2D().getWidth())); Double height = new Double(Math.max(1, shape.getBounds2D().getHeight())); Double shapeHeight = new Double(size); double factor = shapeHeight.doubleValue() / image.getHeight(null); Double shapeWidth = new Double(image.getWidth(null) * factor); AffineTransform transform = AffineTransform.getTranslateInstance(shape.getBounds2D().getMinX(), shape.getBounds2D().getMinY()); Image scaledImage = image.getScaledInstance(shapeWidth.intValue(), shapeHeight.intValue(), Image.SCALE_FAST); BufferedImage buff = new BufferedImage(shapeWidth.intValue(), shapeHeight.intValue(), BufferedImage.TYPE_INT_ARGB); buff.getGraphics().drawImage(scaledImage, 0, 0, null); ParameterBlock p = new ParameterBlock(); p.addSource(buff); p.add(width.intValue()); p.add(height.intValue()); RenderedOp im = JAI.create("pattern", p);//$NON-NLS-1$ BufferedImage bufferedImage = im.getAsBufferedImage(); glDrawImage(bufferedImage, transform, null); bufferedImage.flush(); im.dispose(); scaledImage.flush(); buff.flush(); }
private static void drawGraphicFillPolygon(Image image, float size, Graphics2D graphics, double opacity, double widthSymbol, double heightSymbol, double offsetYSymbol, double offsetXSymbol) { Double shapeHeight = new Double(size); double factor = shapeHeight / image.getHeight(null); Double shapeWidth = new Double(Math.max(image.getWidth(null) * factor, 1)); AffineTransform transform = AffineTransform.getTranslateInstance(offsetXSymbol, offsetYSymbol); Image scaledImage = image.getScaledInstance(shapeWidth.intValue(), shapeHeight.intValue(), Image.SCALE_FAST); BufferedImage buff = new BufferedImage(shapeWidth.intValue(), shapeHeight.intValue(), BufferedImage.TYPE_INT_ARGB); buff.getGraphics().drawImage(scaledImage, 0, 0, null); ParameterBlock p = new ParameterBlock(); p.addSource(buff); p.add((int) widthSymbol); p.add((int) heightSymbol); RenderedOp im = JAI.create("pattern", p);//$NON-NLS-1$ BufferedImage bufferedImage = im.getAsBufferedImage(); graphics.drawImage(bufferedImage, transform, null); bufferedImage.flush(); im.dispose(); scaledImage.flush(); buff.flush(); }
private double computeEdgeDensityClutter(PlanarImage image) { // first compute the RenderedOp that computes both vertical and // horizontal // edge detection KernelJAI sobelVertKernel = KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL; KernelJAI sobelHorizKernel = KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL; ParameterBlock pb = new ParameterBlock(); pb.addSource(image); pb.add(sobelHorizKernel); pb.add(sobelVertKernel); RenderedOp renderedOp = JAI.create("gradientmagnitude", pb); BufferedImage edgeImage = renderedOp.getAsBufferedImage(); // then compute a density value, i.e. the mean int edgeTotal = 0; for (int i = 0; i < edgeImage.getWidth(); i++) for (int j = 0; j < edgeImage.getHeight(); j++) edgeTotal += Math.abs(edgeImage.getRGB(i, j)); return Math.abs(edgeTotal / (edgeImage.getWidth() * edgeImage.getHeight())); }
/** * add a border to image * @param thickness * @param color * @param borderType */ public void addBorder(int thickness, Color color, int borderType) throws ExpressionException{ double colorArray[] = {color.getRed(), color.getGreen(), color.getBlue()}; BorderExtender borderExtender = new BorderExtenderConstant(colorArray); ParameterBlock params = new ParameterBlock(); params.addSource(image()); params.add(thickness); params.add(thickness); params.add(thickness); params.add(thickness); if(BORDER_TYPE_CONSTANT==borderType) params.add(borderExtender); else params.add(BorderExtender.createInstance(borderType)); //else if(BORDER_TYPE_WRAP==borderType)params.add(BorderExtender.createInstance(BorderExtender.BORDER_REFLECT)); image((JAI.create("border", params)).getAsBufferedImage()); }
public void translate(int xtrans, int ytrans, Object interpolation) throws ExpressionException { RenderingHints hints = new RenderingHints(RenderingHints.KEY_INTERPOLATION,interpolation); if(interpolation!=RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR) { hints.add(new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(1))); } ParameterBlock pb = new ParameterBlock(); pb.addSource(image()); BufferedImage img = JAI.create("translate", pb).getAsBufferedImage(); Graphics2D graphics = img.createGraphics(); graphics.clearRect(0, 0, img.getWidth(), img.getHeight()); AffineTransform at = new AffineTransform(); at.setToIdentity(); graphics.drawImage(image(), new AffineTransformOp(at, hints), xtrans, ytrans); graphics.dispose(); image(img); }
public void _rotate(float x, float y, float angle, String interpolation) throws ExpressionException { float radiansAngle = (float)Math.toRadians(angle); // rotation center float centerX = (float)getWidth() / 2; float centerY = (float)getHeight() / 2; ParameterBlock pb = new ParameterBlock(); pb.addSource(image()); pb.add(centerX); pb.add(centerY); pb.add(radiansAngle); pb.add(new javax.media.jai.InterpolationBicubic(10)); // create a new, rotated image image(JAI.create("rotate", pb).getAsBufferedImage()); }
public void crop(float x, float y, float width, float height) throws ExpressionException { ParameterBlock params = new ParameterBlock(); params.addSource(image()); params.add(x); params.add(y); float w = getWidth(); float h = getHeight(); if (w < x + width) params.add(w - x); else params.add(width); if (h < y + height) params.add(h - y); else params.add(height); image(JAI.create("crop", params).getAsBufferedImage()); }
public void blur(int blurFactor) throws ExpressionException{ ParameterBlock params = new ParameterBlock(); params.addSource(image()); params.add(blurFactor); RenderingHints hint= new RenderingHints(JAI.KEY_BORDER_EXTENDER,BorderExtender.createInstance(1)); image(JAI.create("boxfilter", params, hint).getAsBufferedImage()); }
/** * Transforms an ROI using an imaging operation. The operation is * specified by a <code>RenderedImageFactory</code>. The * operation's <code>ParameterBlock</code>, minus the image source * itself is supplied, along with an index indicating where to * insert the ROI image. The <code>renderHints</code> argument * allows rendering hints to be passed in. * * @param RIF A <code>RenderedImageFactory</code> that will be used * to create the op. * @param paramBlock A <code>ParameterBlock</code> containing all * sources and parameters for the op except for the ROI itself. * @param sourceIndex The index of the <code>ParameterBlock</code>'s * sources where the ROI is to be inserted. * @param renderHints A <code>RenderingHints</code> object containing * rendering hints, or null. * @throws IllegalArgumentException if RIF is null. * @throws IllegalArgumentException if paramBlock is null. */ public ROI performImageOp(RenderedImageFactory RIF, ParameterBlock paramBlock, int sourceIndex, RenderingHints renderHints) { if ( RIF == null || paramBlock == null ) { throw new IllegalArgumentException(JaiI18N.getString("Generic0")); } // Clone the ParameterBlock and insert a source ParameterBlock pb = (ParameterBlock) paramBlock.clone(); Vector sources = pb.getSources(); sources.insertElementAt(this.getAsImage(), sourceIndex); // Create a new RenderedImage based on the RIF // and ParameterBlock. RenderedImage im = RIF.create(pb, renderHints); return new ROI(im, threshold); }
/** * Constructor. The down sampler is an "affine" operation that * uses the supplied <code>AffineTransform</code> and * <code>Interpolation</code> objects. * All input parameters are saved by reference. * * @param image The image with the highest resolution. * @param transform An affine matrix used with an "affine" operation * to derive the lower resolution images. * @param interpolation The interpolation method for the "affine" * operation. It may be <code>null</code>, in which case the * default "nearest neighbor" interpolation method is used. * * @throws IllegalArgumentException if <code>image</code> is * <code>null</code>. * @throws IllegalArgumentException if <code>transform</code> is * <code>null</code>. */ public ImageMIPMap(RenderedImage image, AffineTransform transform, Interpolation interpolation) { this(); if ( image == null || transform == null ) { throw new IllegalArgumentException(JaiI18N.getString("Generic0")); } ParameterBlock pb = new ParameterBlock(); pb.addSource(image); pb.add(transform); pb.add(interpolation); downSampler = JAI.create("affine", pb); downSampler.removeSources(); highestImage = image; currentImage = highestImage; }
/** * Constructor. * * @param sourceCollection A collection of rendered images. * @param hints Optionally contains destination image layout. * @param constants The constants to be added, stored as reference. */ public AddConstToCollectionOpImage(Collection sourceCollection, RenderingHints hints, double[] constants) { /** * Try to create a new instance of the sourceCollection to be * used to store output images. If failed, use a Vector. */ try { imageCollection = (Collection)sourceCollection.getClass().newInstance(); } catch (Exception e) { imageCollection = new Vector(); } Iterator iter = sourceCollection.iterator(); while (iter.hasNext()) { ParameterBlock pb = new ParameterBlock(); pb.addSource(iter.next()); pb.add(constants); imageCollection.add(JAI.create("AddConst", pb, hints)); } }
/** * Creates a new instance of <code>MeanOpImage</code> * in the rendered layer. Any image layout information in * <code>RenderingHints</code> is ignored. * This method satisfies the implementation of RIF. */ public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) { RenderedImage src = paramBlock.getRenderedSource(0); int xStart = src.getMinX(); // default values int yStart = src.getMinY(); int maxWidth = src.getWidth(); int maxHeight = src.getHeight(); return new MeanOpImage(src, (ROI)paramBlock.getObjectParameter(0), xStart, yStart, paramBlock.getIntParameter(1), paramBlock.getIntParameter(2)); }
/** * Creates a <code>RenderedOp</code> that takes 1 * <code>RenderedImage</code> source, * 3 <code>float</code> parameters, 1 <code>int</code> parameter and 1 <code>Object</code> parameter. * * @param opName The name of the operation. * @param src The <code>RenderedImage</code> src parameter. * @param param1 The first <code>float</code> parameter. * @param param2 The <code>int</code> parameter. * @param param3 The second <code>float</code> parameter. * @param param4 The third <code>float</code> parameter. * @param param5 The <code>Object</code> parameter. * @deprecated as of JAI 1.1. Instead use * <code>create(String,ParameterBlock)</code>. */ public static RenderedOp create(String opName, RenderedImage src, float param1, int param2, float param3, float param4, Object param5) { ParameterBlock args = new ParameterBlock(); args.addSource(src); args.add(param1); args.add(param2); args.add(param3); args.add(param4); args.add(param5); return create(opName, args, null); }
/** * Maps the output RenderContext into the RenderContext for the ith * source. * This method satisfies the implementation of CRIF. * * @param i The index of the source image. * @param renderContext The renderContext being applied to the operation. * @param paramBlock The ParameterBlock containing the sources * and the translation factors. * @param image The RenderableImageOp from which this method * was called. */ public RenderContext mapRenderContext(int i, RenderContext renderContext, ParameterBlock paramBlock, RenderableImage image) { double scaleX = paramBlock.getDoubleParameter(0); double scaleY = paramBlock.getDoubleParameter(1); AffineTransform scale = new AffineTransform(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0); RenderContext RC = (RenderContext)renderContext.clone(); AffineTransform usr2dev = RC.getTransform(); usr2dev.concatenate(scale); RC.setTransform(usr2dev); return RC; }
/** * Creates a new instance of <code>DivideByConstOpImage</code> in the * rendered layer. * * @param args The source image and the constants. * @param hints Optionally contains destination image layout. */ public RenderedImage create(ParameterBlock args, RenderingHints renderHints) { // Get ImageLayout from renderHints if any. ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints); /* Invert the constants. */ double[] constants = (double[])args.getObjectParameter(0); int length = constants.length; double[] invConstants = new double[length]; for (int i = 0; i < length; i++) { invConstants[i] = 1.0 / constants[i]; } return new MultiplyConstOpImage(args.getRenderedSource(0), renderHints, layout, invConstants); }
/** * Compare the contents of two <code>ParameterBlock</code>s. */ private static int compare(ParameterBlock pb1, ParameterBlock pb2) { if(pb1 == null && pb2 == null) { return PB_EQUAL; } if((pb1 == null && pb2 != null) || (pb1 != null && pb2 == null)) { return PB_DIFFER; } int result = PB_EQUAL; if(!equals(pb1.getSources(), pb2.getSources())) { result |= PB_SOURCES_DIFFER; } if(!equals(pb1.getParameters(), pb2.getParameters())) { result |= PB_PARAMETERS_DIFFER; } return result; }
/** * Validates the input parameters. * * <p> In addition to the standard checks performed by the * superclass method, this method checks that "xScale" and "yScale" * are both greater than 0. */ protected boolean validateParameters(ParameterBlock args, StringBuffer msg) { if (!super.validateParameters(args, msg)) { return false; } float xScale = args.getFloatParameter(0); float yScale = args.getFloatParameter(1); if (xScale <= 0 || yScale <= 0) { msg.append(getName() + " " + JaiI18N.getString("ScaleDescriptor6")); return false; } return true; }
/** * Validates the input sources. * * <p> In addition to the standard checks performed by the * superclass method, this method checks that the source images * each have an even number of bands. */ protected boolean validateSources(String modeName, ParameterBlock args, StringBuffer msg) { if (!super.validateSources(modeName, args, msg)) { return false; } if (!modeName.equalsIgnoreCase("rendered")) return true; RenderedImage src1 = args.getRenderedSource(0); RenderedImage src2 = args.getRenderedSource(1); if (src1.getSampleModel().getNumBands() % 2 != 0 || src2.getSampleModel().getNumBands() % 2 != 0) { msg.append(getName() + " " + JaiI18N.getString("MultiplyComplexDescriptor1")); return false; } return true; }
/** * Constructor. * * @param paramIndex The index of the associated parameter. * @param dd The <code>DeferredData</code> object to observe. */ ParamObserver(int paramIndex, DeferredData dd) { if(dd == null) { throw new IllegalArgumentException(JaiI18N.getString("Generic0")); } else if(paramIndex < 0 || (pb != null && (paramIndex >= ((ParameterBlock)pb).getNumParameters()))) { throw new ArrayIndexOutOfBoundsException(); } this.paramIndex = paramIndex; this.dd = dd; // Add this object as an Observer of the Deferred Data. dd.addObserver(this); }
/** * Performs an affine transformation and returns the result as a new * ROI. The transformation is performed by an "Affine" RIF using the * indicated interpolation method. * * @param at an AffineTransform specifying the transformation. * @param interp the Interpolation to be used. * @throws IllegalArgumentException if at is null. * @throws IllegalArgumentException if interp is null. * @return a new ROI containing the transformed ROI data. */ public ROI transform(AffineTransform at, Interpolation interp) { if (at == null) { throw new IllegalArgumentException(JaiI18N.getString("ROI5")); } if (interp == null) { throw new IllegalArgumentException(JaiI18N.getString("ROI6")); } ParameterBlock paramBlock = new ParameterBlock(); paramBlock.add(at); paramBlock.add(interp); return performImageOp("Affine", paramBlock, 0, null); }
/** * Gets the output bounding box in rendering-independent space. * This method satisfies the implementation of CRIF. */ public Rectangle2D getBounds2D(ParameterBlock paramBlock) { RenderableImage mres = createRenderable(paramBlock); return new Rectangle2D.Float(mres.getMinX(), mres.getMinY(), mres.getWidth(), mres.getHeight()); }
/** * Validates the input source. * * <p> In addition to the standard checks performed by the * superclass method, this method checks that the source image * is of integral data type. */ protected boolean validateSources(String modeName, ParameterBlock args, StringBuffer msg) { if (!super.validateSources(modeName, args, msg)) { return false; } if (!modeName.equalsIgnoreCase("rendered")) return true; RenderedImage src = args.getRenderedSource(0); int dtype = src.getSampleModel().getDataType(); if (dtype != DataBuffer.TYPE_BYTE && dtype != DataBuffer.TYPE_USHORT && dtype != DataBuffer.TYPE_SHORT && dtype != DataBuffer.TYPE_INT) { msg.append(getName() + " " + JaiI18N.getString("NotDescriptor1")); return false; } return true; }
/** * Validates the input parameter. * * <p> In addition to the standard checks performed by the * superclass method, this method checks that the length of the * "constants" array is at least 1. */ protected boolean validateParameters(ParameterBlock args, StringBuffer message) { if (!super.validateParameters(args, message)) { return false; } int length = ((double[])args.getObjectParameter(0)).length; if (length < 1) { message.append(getName() + " " + JaiI18N.getString("SubtractFromConstDescriptor2")); return false; } return true; }
/** * Creates a <code>RenderedOp</code> that takes 1 <code>RenderedImage</code> source, * 5 <code>int</code> parameters and 1 <code>Object</code> parameter. * * @param opName The name of the operation. * @param src The <code>RenderedImage</code> src parameter. * @param param1 The first <code>int</code> parameter. * @param param2 The second <code>int</code> parameter. * @param param3 The third <code>int</code> parameter. * @param param4 The fourth <code>int</code> parameter. * @param param5 The fifth <code>int</code> parameter. * @param param6 The <code>Object</code> parameter. * @deprecated as of JAI 1.1. Instead use * <code>create(String,ParameterBlock)</code>. */ public static RenderedOp create(String opName, RenderedImage src, int param1, int param2, int param3, int param4, int param5, Object param6) { ParameterBlock args = new ParameterBlock(); args.addSource(src); args.add(param1); args.add(param2); args.add(param3); args.add(param4); args.add(param5); args.add(param6); return create(opName, args, null); }
/** * Creates a new instance of <code>OverlayOpImage</code> * in the rendered layer. * * @param args The two source images. * @param hints Optionally contains destination image layout. */ public RenderedImage create(ParameterBlock args, RenderingHints renderHints) { // Get ImageLayout from renderHints if any. ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints); return new OverlayOpImage(args.getRenderedSource(0), args.getRenderedSource(1), renderHints, layout); }
/** * Returns the bounding box for the output of the operation. The * implementation in this class computes the bounding box as the * intersection the bounding boxes of all the (renderable sources). * * @param paramBlock A <code>ParameterBlock</code> containing the * sources and parameters of the operation. * @return A <code>Rectangle2D</code> specifying the bounding box. */ public Rectangle2D getBounds2D(ParameterBlock paramBlock) { int numSources = paramBlock.getNumSources(); if (numSources == 0) { return null; } RenderableImage src = paramBlock.getRenderableSource(0); Rectangle2D.Float box1 = new Rectangle2D.Float(src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight()); for (int i = 1; i < numSources; i++) { src = paramBlock.getRenderableSource(i); Rectangle2D.Float box2 = new Rectangle2D.Float(src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight()); box1 = (Rectangle2D.Float)box1.createIntersection(box2); if(box1.isEmpty()) { break; } } return box1; }
/** * Creates a <code>RenderedOp</code> that takes 1 * <code>RenderedImage</code> source and * 5 <code>Object</code> parameters. * * @param opName The name of the operation. * @param src The <code>RenderedImage</code> src parameter. * @param param1 The first <code>Object</code> parameter. * @param param2 The second <code>Object</code> parameter. * @param param3 The third <code>Object</code> parameter. * @param param4 The fourth <code>Object</code> parameter. * @param param5 The fifth <code>Object</code> parameter. * @deprecated as of JAI 1.1. Instead use * <code>create(String,ParameterBlock)</code>. */ public static RenderedOp create(String opName, RenderedImage src, Object param1, Object param2, Object param3, Object param4, Object param5) { ParameterBlock args = new ParameterBlock(); args.addSource(src); args.add(param1); args.add(param2); args.add(param3); args.add(param4); args.add(param5); return create(opName, args, null); }
/** * Creates a <code>RenderedOp</code> that takes 1 <code>RenderedImage</code> source, * 4 <code>float</code> parameters and one <code>Object</code> parameter. * * @param opName The name of the operation. * @param src The <code>RenderedImage</code> src parameter. * @param param1 The first <code>float</code> parameter. * @param param2 The second <code>float</code> parameter. * @param param3 The third <code>float</code> parameter. * @param param4 The fourth <code>float</code> parameter. * @param param5 The <code>Object</code> parameter. * @deprecated as of JAI 1.1. Instead use * <code>create(String,ParameterBlock)</code>. */ public static RenderedOp create(String opName, RenderedImage src, float param1, float param2, float param3, float param4, Object param5) { ParameterBlock args = new ParameterBlock(); args.addSource(src); args.add(param1); args.add(param2); args.add(param3); args.add(param4); args.add(param5); return create(opName, args, null); }
/** * Creates a <code>RenderedOp</code> that takes 1 * <code>RenderedImage</code> source and * 6 <code>Object</code> parameters. * * @param opName The name of the operation. * @param src The <code>RenderedImage</code> src parameter. * @param param1 The first <code>Object</code> parameter. * @param param2 The second <code>Object</code> parameter. * @param param3 The third <code>Object</code> parameter. * @param param4 The fourth <code>Object</code> parameter. * @param param5 The fifth <code>Object</code> parameter. * @param param6 The sixth <code>Object</code> parameter. * @deprecated as of JAI 1.1. Instead use * <code>create(String,ParameterBlock)</code>. */ public static RenderedOp create(String opName, RenderedImage src, Object param1, Object param2, Object param3, Object param4, Object param5, Object param6) { ParameterBlock args = new ParameterBlock(); args.addSource(src); args.add(param1); args.add(param2); args.add(param3); args.add(param4); args.add(param5); args.add(param6); return create(opName, args, null); }
/** * Creates a new instance of <code>BandMergeOpImage</code> in the * rendered layer. This method satisifies the implementation of RIF. * * @param paramBlock The two or more source images to be "BandMerged" * together, and their corresponding float array vector. * @param renderHints Optionally contains destination image layout. */ public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) { // Get ImageLayout from renderHints if any. ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints); // get vector of RenderedImage sources and parameters Vector sources = paramBlock.getSources(); //Vector params = paramBlock.getParameters(); return new BandMergeOpImage(sources, renderHints, layout); }
/** * Creates a new instance of <code>CropOpImage</code> in the * rendered layer. * * @param args The source image and bounding rectangle * @param hints Optionally contains destination image layout. */ public RenderedImage create(ParameterBlock args, RenderingHints renderHints) { // Get the source image. RenderedImage src = (RenderedImage)args.getRenderedSource(0); // Get the parameters. float originX = args.getFloatParameter(0); float originY = args.getFloatParameter(1); float width = args.getFloatParameter(2); float height = args.getFloatParameter(3); // Return the OpImage. return new CropOpImage(src, originX, originY, width, height); }
/** * Constructs and returns a <code>PropertySource</code> suitable for * use by a given <code>OperationNode</code>. The * <code>PropertySource</code> includes properties copied from prior * nodes as well as those generated at the node itself. Additionally, * property suppression is taken into account. The actual * implementation of <code>getPropertySource()</code> may make use * of deferred execution and caching. * * @param op the <code>OperationNode</code> requesting its * <code>PropertySource</code>. * * @throws IllegalArgumentException if op is null. * * @since JAI 1.1 */ public PropertySource getPropertySource(OperationNode op) { 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 // source Vector. if(pv == null) { pv = new Vector(); } return getPropertySource(op.getRegistryModeName(), op.getOperationName(), op, pv); }
/** * Creates a new instance of <code>PeriodicShiftOpImage</code> * in the rendered layer. This method satisfies the * implementation of RIF. */ public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) { // Get ImageLayout from renderHints if any. ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints); // Get the source image. RenderedImage source = paramBlock.getRenderedSource(0); // Get the translation parameters. int shiftX = paramBlock.getIntParameter(0); int shiftY = paramBlock.getIntParameter(1); // Return the OpImage. return new PeriodicShiftOpImage(source, renderHints, layout, shiftX, shiftY); }