this.imageLayout = new ImageLayout2( layout.getMinX(null), layout.getMinY(null), originalSampleModel.getWidth(),
int minXL = result.getMinX(source); int minYL = result.getMinY(source); int maxXL = result.getWidth(source) + minXL;
| ImageLayout.TILE_GRID_Y_OFFSET_MASK)) == 0) { layout.setTileGridXOffset(layout.getMinX(sourceImage)); layout.setTileGridYOffset(layout.getMinY(sourceImage)); final int width = layout.getWidth(sourceImage);
| ImageLayout.TILE_GRID_Y_OFFSET_MASK)) == 0) { layout.setTileGridXOffset(layout.getMinX(sourceImage)); layout.setTileGridYOffset(layout.getMinY(sourceImage)); final int width = layout.getWidth(sourceImage);
public Properties getAsProperties(Properties defaultProperties) { final Properties properties = new Properties(defaultProperties); properties.setProperty("dataType", imageLayout.getSampleModel(null).getDataType() + ""); properties.setProperty("minX", imageLayout.getMinX(null) + ""); properties.setProperty("minY", imageLayout.getMinY(null) + ""); properties.setProperty("width", imageLayout.getWidth(null) + ""); properties.setProperty("height", imageLayout.getHeight(null) + ""); properties.setProperty("tileGridXOffset", imageLayout.getTileGridXOffset(null) + ""); properties.setProperty("tileGridYOffset", imageLayout.getTileGridYOffset(null) + ""); properties.setProperty("tileWidth", imageLayout.getTileWidth(null) + ""); properties.setProperty("tileHeight", imageLayout.getTileHeight(null) + ""); properties.setProperty("tileFormat", tileFormat); return properties; } }
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 OperatorImage(Band targetBand, OperatorContext operatorContext, ImageLayout imageLayout) { super(imageLayout, operatorContext.getRenderingHints(), imageLayout.getSampleModel(null), imageLayout.getMinX(null), imageLayout.getMinY(null), imageLayout.getWidth(null), imageLayout.getHeight(null)); this.targetBand = targetBand; this.operatorContext = operatorContext; OperatorContext.setTileCache(this); }
private WarpSourceCoordinatesOpImage(Warp warp, ImageLayout layout, Map configuration) { super(layout, configuration, layout.getSampleModel(null), layout.getMinX(null), layout.getMinY(null), layout.getWidth(null), layout.getHeight(null)); this.warp = warp; int compatibleTag = RasterAccessor.findCompatibleTag(null, layout.getSampleModel(null)); rasterFormatTag = new RasterFormatTag(layout.getSampleModel(null), compatibleTag); OperatorContext.setTileCache(this); }
private void testGetLevelImageBounds(int expectedSize, int size, int level, DefaultMultiLevelModel model) { Rectangle expected = new Rectangle(0, 0, expectedSize, expectedSize); ResolutionLevel resolutionLevel = new ResolutionLevel(level, model.getScale(level)); ImageLayout imageLayout = ImageManager.createSingleBandedImageLayout(DataBuffer.TYPE_USHORT, size, size, null, resolutionLevel); assertEquals("at resolution level " + level + ":", expected, new Rectangle(imageLayout.getMinX(null), imageLayout.getMinY(null), imageLayout.getWidth(null), imageLayout.getHeight(null)) ); }
private WarpSourceCoordinatesOpImage(Warp warp, ImageLayout layout, Map configuration) { super(layout, configuration, layout.getSampleModel(null), layout.getMinX(null), layout.getMinY(null), layout.getWidth(null), layout.getHeight(null)); this.warp = warp; int compatibleTag = RasterAccessor.findCompatibleTag(null, layout.getSampleModel(null)); rasterFormatTag = new RasterFormatTag(layout.getSampleModel(null), compatibleTag); OperatorContext.setTileCache(this); }
private TiledFileOpImage(ImageHeader imageHeader, Map configuration, VirtualDir imageDir) throws IOException { super(imageHeader.getImageLayout(), configuration, imageHeader.getImageLayout().getSampleModel(null), imageHeader.getImageLayout().getMinX(null), imageHeader.getImageLayout().getMinY(null), imageHeader.getImageLayout().getWidth(null), imageHeader.getImageLayout().getHeight(null)); this.imageDir = imageDir; this.imageHeader = imageHeader; if (this.imageHeader.getTileFormat().equalsIgnoreCase("raw.zip")) { inputStreamFactory = new RawZipImageInputStreamFactory(); } else if (this.imageHeader.getTileFormat().equalsIgnoreCase("raw")) { inputStreamFactory = new RawImageInputStreamFactory(); } else if (this.imageHeader.getTileFormat().equalsIgnoreCase("zip")) { inputStreamFactory = new ZipInputStreamFactory(); } if (getTileCache() == null) { setTileCache(JAI.getDefaultInstance().getTileCache()); } }
private SingleBandedOpImage(ImageLayout layout, int sourceWidth, int sourceHeight, Map configuration, ResolutionLevel level) { super(layout, configuration, layout.getSampleModel(null), layout.getMinX(null), layout.getMinY(null), layout.getWidth(null), layout.getHeight(null)); levelImageSupport = new LevelImageSupport(sourceWidth, sourceHeight, level); if (getTileCache() == null) { setTileCache(JAI.getDefaultInstance().getTileCache()); } }
/** * 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; }
| ImageLayout.TILE_HEIGHT_MASK | ImageLayout.TILE_GRID_X_OFFSET_MASK | ImageLayout.TILE_GRID_Y_OFFSET_MASK)) == 0) { layout.setTileGridXOffset(layout.getMinX(sourceImage)); layout.setTileGridYOffset(layout.getMinY(sourceImage)); final int width = layout.getWidth(sourceImage);
/** * 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; }
/** * 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));
public void testLoadBitImage() throws IOException { final ImageHeader imageHeader = ImageHeader.load( new InputStreamReader(ImageHeaderTest.class.getResourceAsStream("bit-image.properties")), null, null); assertEquals("raw", imageHeader.getTileFormat()); final ImageLayout imageLayout = imageHeader.getImageLayout(); assertNotNull(imageLayout); assertEquals(1, imageLayout.getMinX(null)); assertEquals(-1, imageLayout.getMinY(null)); assertEquals(1280, imageLayout.getWidth(null)); assertEquals(1024, imageLayout.getHeight(null)); assertEquals(0, imageLayout.getTileGridXOffset(null)); assertEquals(6, imageLayout.getTileGridYOffset(null)); assertEquals(512, imageLayout.getTileWidth(null)); assertEquals(256, imageLayout.getTileHeight(null)); assertNull(imageLayout.getColorModel(null)); assertNotNull(imageLayout.getSampleModel(null)); assertEquals(512, imageLayout.getSampleModel(null).getWidth()); assertEquals(256, imageLayout.getSampleModel(null).getHeight()); assertEquals(1, imageLayout.getSampleModel(null).getNumBands()); assertEquals(0, imageLayout.getSampleModel(null).getDataType()); assertEquals(1, imageLayout.getSampleModel(null).getSampleSize()[0]); }
public void testLoadFloatImage() throws IOException { final ImageHeader imageHeader = ImageHeader.load( new InputStreamReader(ImageHeaderTest.class.getResourceAsStream("float-image.properties")), null, null); assertEquals("raw", imageHeader.getTileFormat()); final ImageLayout imageLayout = imageHeader.getImageLayout(); assertNotNull(imageLayout); assertEquals(1, imageLayout.getMinX(null)); assertEquals(-1, imageLayout.getMinY(null)); assertEquals(1280, imageLayout.getWidth(null)); assertEquals(1024, imageLayout.getHeight(null)); assertEquals(0, imageLayout.getTileGridXOffset(null)); assertEquals(6, imageLayout.getTileGridYOffset(null)); assertEquals(512, imageLayout.getTileWidth(null)); assertEquals(256, imageLayout.getTileHeight(null)); assertNull(imageLayout.getColorModel(null)); assertNotNull(imageLayout.getSampleModel(null)); assertEquals(512, imageLayout.getSampleModel(null).getWidth()); assertEquals(256, imageLayout.getSampleModel(null).getHeight()); assertEquals(1, imageLayout.getSampleModel(null).getNumBands()); assertEquals(4, imageLayout.getSampleModel(null).getDataType()); assertEquals(32, imageLayout.getSampleModel(null).getSampleSize()[0]); }