/** * If the was not already tiled, tile it. Note that no tiling will be done if * 'getRenderingHints()' failed to suggest a tile size. This method is for internal use by * {@link #write} methods only. * * @return this {@link ImageWorker}. */ public final ImageWorker tile() { final RenderingHints hints = getRenderingHints(); final ImageLayout layout = getImageLayout(hints); if (layout.isValid(ImageLayout.TILE_WIDTH_MASK) || layout.isValid(ImageLayout.TILE_HEIGHT_MASK)) { final int type = image.getSampleModel().getDataType(); // ParameterBlock definition ParameterBlock pb = new ParameterBlock(); pb.setSource(image, 0); // The source image. pb.set(type, 0); image = JAI.create("Format", pb, hints); setNoData(RangeFactory.convert(nodata, type)); } return this; }
if (result.isValid(ImageLayout.TILE_WIDTH_MASK)) { final int oldSize = result.getTileWidth(source); final int newSize = toTileSize(result.getWidth(source), oldSize); if (result.isValid(ImageLayout.TILE_HEIGHT_MASK)) { final int oldSize = result.getTileHeight(source); final int newSize = toTileSize(result.getHeight(source), oldSize);
if (layout.isValid(ImageLayout.COLOR_MODEL_MASK)) { return hints;
if (layout == null || !layout.isValid(ImageLayout.COLOR_MODEL_MASK)) { if (sampleDims != null && sampleDims.length != 0) { int visibleBand =
/** * If the was not already tiled, tile it. Note that no tiling will be done * if 'getRenderingHints()' failed to suggest a tile size. This method is * for internal use by {@link #write} methods only. * * @return this {@link ImageWorker}. */ public final ImageWorker tile() { final RenderingHints hints = getRenderingHints(); final ImageLayout layout = getImageLayout(hints); if (layout.isValid(ImageLayout.TILE_WIDTH_MASK) || layout.isValid(ImageLayout.TILE_HEIGHT_MASK)) { final int type = image.getSampleModel().getDataType(); image = FormatDescriptor.create(image, new Integer(type), hints); } return this; }
private static RenderingHints createDefaultRenderingHints(RenderedImage sourceImage, ImageLayout targetLayout) { Map<RenderingHints.Key, Object> map = new HashMap<>(7); if (!CACHE_INTERMEDIATE_TILES) { map.put(JAI.KEY_TILE_CACHE, null); } if (sourceImage != null) { if (targetLayout == null) { targetLayout = new ImageLayout(); } if (!targetLayout.isValid(ImageLayout.TILE_GRID_X_OFFSET_MASK)) { targetLayout.setTileGridXOffset(sourceImage.getTileGridXOffset()); } if (!targetLayout.isValid(ImageLayout.TILE_GRID_Y_OFFSET_MASK)) { targetLayout.setTileGridYOffset(sourceImage.getTileGridYOffset()); } if (!targetLayout.isValid(ImageLayout.TILE_WIDTH_MASK)) { targetLayout.setTileWidth(sourceImage.getTileWidth()); } if (!targetLayout.isValid(ImageLayout.TILE_HEIGHT_MASK)) { targetLayout.setTileHeight(sourceImage.getTileHeight()); } map.put(JAI.KEY_IMAGE_LAYOUT, targetLayout); } return new RenderingHints(map); }
/** * If the was not already tiled, tile it. Note that no tiling will be done * if 'getRenderingHints()' failed to suggest a tile size. This method is * for internal use by {@link #write} methods only. * * @return this {@link ImageWorker}. */ public final ImageWorker tile() { final RenderingHints hints = getRenderingHints(); final ImageLayout layout = getImageLayout(hints); if (layout.isValid(ImageLayout.TILE_WIDTH_MASK) || layout.isValid(ImageLayout.TILE_HEIGHT_MASK)) { final int type = image.getSampleModel().getDataType(); image = FormatDescriptor.create(image, type, hints); } return this; }
layout = new ImageLayout(); if (visibleBand != null || !layout.isValid(ImageLayout.COLOR_MODEL_MASK)) { ColorModel colors = sourceImage.getColorModel(); if (colors instanceof IndexColorModel
/** Helper function for creating a suitable sample model for the final image */ private static SampleModel sampleModelHelper(int numBands, ImageLayout layout) { SampleModel sampleModel; if (layout != null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) { sampleModel = layout.getSampleModel(null); if (sampleModel.getNumBands() != numBands) { throw new RuntimeException(JaiI18N.getString("ImageFunctionRIF0")); } } else { // Create a SampleModel. // Use a dummy width and height, OpImage will fix them sampleModel = RasterFactory.createBandedSampleModel(DataBuffer.TYPE_FLOAT, 1, 1, numBands); } return sampleModel; }
/** * Create a new ImageLayout from the source image optionally overriding a ColorModel supplied via the layout. */ private static ImageLayout layoutHelper(RenderedImage source, ImageLayout layout) { // Create basic layout from the source. ImageLayout il = new ImageLayout(source); // If a layout containing a valid ColorModel field is supplied then // reset the ColorModel if it is compatible with the SampleModel. if(layout != null && layout.isValid(ImageLayout.COLOR_MODEL_MASK)) { ColorModel colorModel = layout.getColorModel(null); if(JDKWorkarounds.areCompatibleDataModels(source.getSampleModel(), colorModel)) { il.setColorModel(colorModel); } } return il; }
/** * Create a new ImageLayout from the source image optionally overriding a ColorModel supplied via the layout. */ private static ImageLayout layoutHelper(RenderedImage source, ImageLayout layout) { // Create basic layout from the source. ImageLayout il = new ImageLayout(source); // If a layout containing a valid ColorModel field is supplied then // reset the ColorModel if it is compatible with the SampleModel. if(layout != null && layout.isValid(ImageLayout.COLOR_MODEL_MASK)) { ColorModel colorModel = layout.getColorModel(null); if(JDKWorkarounds.areCompatibleDataModels(source.getSampleModel(), colorModel)) { il.setColorModel(colorModel); } } return il; }
/** * Builds an {@code ImageLayout} for this image. The {@code width} and * {@code height} arguments are requested tile dimensions which will * only be used if they are smaller than this operator's default * tile dimension. * * @param minX origin X ordinate * @param minY origin Y ordinate * @param width requested tile width * @param height requested tile height * @param sm sample model * * @return the {@code ImageLayout} object */ static ImageLayout buildLayout(int minX, int minY, int width, int height, SampleModel sm) { // build a sample model for the single tile ImageLayout il = new ImageLayout(); il.setMinX(minX); il.setMinY(minY); il.setWidth(width); il.setHeight(height); il.setSampleModel(sm); if (!il.isValid(ImageLayout.TILE_GRID_X_OFFSET_MASK)) { il.setTileGridXOffset(il.getMinX(null)); } if (!il.isValid(ImageLayout.TILE_GRID_Y_OFFSET_MASK)) { il.setTileGridYOffset(il.getMinY(null)); } return il; }
if (layout.isValid(ImageLayout.COLOR_MODEL_MASK)) { return hints;
/** * Sets up the image layout information for this Operation. The minX, minY, width, and height are calculated based on the source's dimension and * padding values. Any of these values specified in the layout parameter is ignored. All other variables are taken from the layout parameter or * inherited from the source. */ private static ImageLayout layoutHelper(ImageLayout layout, RenderedImage source, int leftPad, int rightPad, int topPad, int bottomPad) { ImageLayout il = layout == null ? new ImageLayout() : (ImageLayout) layout.clone(); // Set the image bounds according to the padding. il.setMinX(source.getMinX() - leftPad); il.setMinY(source.getMinY() - topPad); il.setWidth(source.getWidth() + leftPad + rightPad); il.setHeight(source.getHeight() + topPad + bottomPad); // Set tile grid offset to minimize the probability that a // tile's bounds does not intersect the source image bounds. if (!il.isValid(ImageLayout.TILE_GRID_X_OFFSET_MASK)) { il.setTileGridXOffset(il.getMinX(null)); } if (!il.isValid(ImageLayout.TILE_GRID_Y_OFFSET_MASK)) { il.setTileGridYOffset(il.getMinY(null)); } // Force inheritance of source image SampleModel and ColorModel. il.setSampleModel(source.getSampleModel()); il.setColorModel(source.getColorModel()); return il; }
if (layout != null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK) && layout.getSampleModel(null).getNumBands() != numBandsRequired) { throw new RuntimeException(JaiI18N.getString("ImageFunctionRIF0")); int minY = 0; if (layout != null) { if (layout.isValid(ImageLayout.MIN_X_MASK)) { minX = layout.getMinX(null); if (layout.isValid(ImageLayout.MIN_Y_MASK)) { minY = layout.getMinX(null);
/** * Builds an {@code ImageLayout} for this image. The {@code width} and {@code height} arguments are requested tile dimensions which will only be * used if they are smaller than this operator's default tile dimension. * * @param minX origin X ordinate * @param minY origin Y ordinate * @param width requested tile width * @param height requested tile height * @param sm sample model * * @return the {@code ImageLayout} object */ static ImageLayout buildLayout(int minX, int minY, int width, int height, SampleModel sm) { // build a sample model for the single tile ImageLayout il = new ImageLayout(); il.setMinX(minX); il.setMinY(minY); il.setWidth(width); il.setHeight(height); il.setTileWidth(sm.getWidth()); il.setTileHeight(sm.getHeight()); il.setSampleModel(sm); if (!il.isValid(ImageLayout.TILE_GRID_X_OFFSET_MASK)) { il.setTileGridXOffset(il.getMinX(null)); } if (!il.isValid(ImageLayout.TILE_GRID_Y_OFFSET_MASK)) { il.setTileGridYOffset(il.getMinY(null)); } return il; }
if (layout.isValid(ImageLayout.COLOR_MODEL_MASK)) { return hints;
/** * Builds an {@code ImageLayout} for this image. The {@code width} and {@code height} arguments are requested tile dimensions which will only be * used if they are smaller than this operator's default tile dimension. * * @param minX origin X ordinate * @param minY origin Y ordinate * @param width requested tile width * @param height requested tile height * @param sm sample model * * @return the {@code ImageLayout} object */ static ImageLayout buildLayout(int minX, int minY, int width, int height, SampleModel sm) { // build a sample model for the single tile ImageLayout il = new ImageLayout(); il.setMinX(minX); il.setMinY(minY); il.setWidth(width); il.setHeight(height); il.setTileWidth(sm.getWidth()); il.setTileHeight(sm.getHeight()); il.setSampleModel(sm); if (!il.isValid(ImageLayout.TILE_GRID_X_OFFSET_MASK)) { il.setTileGridXOffset(il.getMinX(null)); } if (!il.isValid(ImageLayout.TILE_GRID_Y_OFFSET_MASK)) { il.setTileGridYOffset(il.getMinY(null)); } return il; }