/** * Creates a SampleOpImage with the given ParameterBlock if the SampleOpImage can handle the * particular ParameterBlock. */ @Override public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) { PlanarImage source1 = (PlanarImage) paramBlock.getRenderedSource(0); if (source1 == null) { return null; } ROIShape shape = (ROIShape) paramBlock.getObjectParameter(0); if (shape == null) { return source1; } TiledImage image; if (ImageUtil.isBinary(source1.getSampleModel())) { image = new TiledImage( source1.getMinX(), source1.getMinY(), source1.getWidth(), source1.getHeight(), source1.getTileGridXOffset(), source1.getTileGridYOffset(), LayoutUtil.createBinarySampelModel(), LayoutUtil.createBinaryIndexColorModel()); } else { // rgb cannot be null or have less than one value Byte[] rgb = (Byte[]) paramBlock.getObjectParameter(1); int nbands = source1.getSampleModel().getNumBands(); if (rgb.length != nbands) { Byte fillVal = rgb[0]; rgb = new Byte[nbands]; Arrays.fill(rgb, fillVal); } image = ImageFiler.getEmptyTiledImage(rgb, source1.getWidth(), source1.getHeight()); } image.set(source1, shape); return image; }