final int tileHeight = Integer.parseInt(tilesSize[1].trim()); layout = new ImageLayout(); layout.setTileGridXOffset(0) .setTileGridYOffset(0) .setTileHeight(tileHeight)
private void setupTilingHints(final int tileSizeX, final int tileSizeY) { //// // // TILING // //// if (tileSizeX > 0 && tileSizeY > 0) { // Tile Size final ImageLayout layout = new ImageLayout2(); layout.setTileGridXOffset(0) .setTileGridYOffset(0) .setTileHeight(tileSizeY) .setTileWidth(tileSizeX); hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout)); } }
layout.setTileGridXOffset(image.getMinX()); layout.setTileGridYOffset(image.getMinY()); hints.put(JAI.KEY_IMAGE_LAYOUT, layout);
tileDimensions = (Dimension) JAI.getDefaultTileSize().clone(); layout.setTileGridXOffset(0).setTileGridYOffset(0); layout.setTileHeight(tileDimensions.height).setTileWidth(tileDimensions.width);
layout.setTileGridXOffset(image.getMinX()); } else if (image.getTileWidth() <= STRIPE_SIZE) { if (layout == null) {
| ImageLayout.TILE_GRID_Y_OFFSET_MASK)) == 0) { layout.setTileGridXOffset(layout.getMinX(sourceImage)); layout.setTileGridYOffset(layout.getMinY(sourceImage)); final int width = layout.getWidth(sourceImage);
il.setTileGridXOffset(0); il.setTileGridYOffset(0); localHints.put(JAI.KEY_IMAGE_LAYOUT, il);
newHints = hints.clone(); final ImageLayout layout = new ImageLayout(); layout.setTileGridXOffset(0); layout.setTileGridYOffset(0); layout.setTileHeight(suggestedTileSize[1]);
| ImageLayout.TILE_GRID_Y_OFFSET_MASK)) == 0) { layout.setTileGridXOffset(layout.getMinX(sourceImage)); layout.setTileGridYOffset(layout.getMinY(sourceImage)); final int width = layout.getWidth(sourceImage);
/** * @param param */ private void setTileSize(ParameterValue<?> param) { final String suggestedTileSize = (String) param.getValue(); // Preliminary checks on parameter value if ((suggestedTileSize != null)&& (suggestedTileSize.trim().length() > 0)) { if (suggestedTileSize.contains(BaseGDALGridFormat.TILE_SIZE_SEPARATOR)) { final String[] tilesSize = suggestedTileSize.split(BaseGDALGridFormat.TILE_SIZE_SEPARATOR); if (tilesSize.length == 2) { try { // Getting suggested tile size final int tileWidth = Integer.parseInt(tilesSize[0].trim()); final int tileHeight = Integer.parseInt(tilesSize[1].trim()); layout = new ImageLayout(); layout.setTileGridXOffset(0).setTileGridYOffset(0).setTileHeight(tileHeight).setTileWidth(tileWidth); } catch (NumberFormatException nfe) { //reset previously set layout layout=null; if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.log(Level.WARNING, "Unable to parse "+ "suggested tile size parameter",nfe); } } } } } }
private static ImageLayout getImageLayout(BufferedImage im) { // a subimage generates a wrong tile layout, set it manually ImageLayout il = new ImageLayout(im); il.unsetTileLayout(); il.setTileGridXOffset(0); il.setTileGridYOffset(0); il.setTileWidth(im.getWidth()); il.setTileHeight(im.getHeight()); return il; }
private static ImageLayout getImageLayout(BufferedImage im) { // a subimage generates a wrong tile layout, set it manually ImageLayout il = new ImageLayout(im); il.unsetTileLayout(); il.setTileGridXOffset(0); il.setTileGridYOffset(0); il.setTileWidth(im.getWidth()); il.setTileHeight(im.getHeight()); return il; }
new Dimension(layout.getWidth(sourceImage), layout.getHeight(sourceImage)); size = ImageUtilities.toTileSize(size); layout.setTileGridXOffset(layout.getMinX(sourceImage)); layout.setTileGridYOffset(layout.getMinY(sourceImage)); layout.setTileWidth(size.width);
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); }
/** * This method has the objective of untiling the final image to write on * disk since we do not want to have tiles added to the file on disk causing * failures when reading it back into memory. * * @param image * Image to untile. * * @return Untiled image. */ private PlanarImage untileImage(RenderedImage image) { final ParameterBlockJAI pbj = new ParameterBlockJAI("format"); pbj.addSource(image); pbj.setParameter("dataType", image.getSampleModel().getTransferType()); final ImageLayout layout = new ImageLayout(image); layout.unsetTileLayout(); layout.setTileGridXOffset(0); layout.setTileGridYOffset(0); layout.setTileHeight(image.getHeight()); layout.setTileWidth(image.getWidth()); layout.setValid(ImageLayout.TILE_GRID_X_OFFSET_MASK | ImageLayout.TILE_GRID_Y_OFFSET_MASK | ImageLayout.TILE_HEIGHT_MASK | ImageLayout.TILE_WIDTH_MASK); final RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout); // avoid caching this image return JAI.create("format", pbj, 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; }
/** * 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; }
/** * 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; }
il.setTileGridXOffset(il.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; }