private String getTileFilename(int tileX, int tileY) { return getTileBasename(tileX, tileY) + "." + imageHeader.getTileFormat(); }
/** * Computes a tile. Since the operation has no sources, * there is no need to worry about cobbling. * <p/> * <p> Subclasses should implement the * <code>computeRect(PlanarImage[], WritableRaster, Rectangle)</code> * method to perform the actual computation. * * @param tileX The X index of the tile. * @param tileY The Y index of the tile. */ @Override public Raster computeTile(int tileX, int tileY) { // System.out.println("TiledFileOpImage.computeTile: >> '" + getTileFilename(tileX, tileY) + "'..."); final Point location = new Point(tileXToX(tileX), tileYToY(tileY)); final Raster raster; if (imageHeader.getTileFormat().startsWith("raw")) { final WritableRaster targetRaster = createWritableRaster(sampleModel, location); try { readRawDataTile(tileX, tileY, targetRaster); } catch (IOException e) { throw new RuntimeException("Failed to read image tile.", e); } raster = targetRaster; } else { raster = readImageTile(tileX, tileY, location); } // System.out.println("TiledFileOpImage.computeTile: << '" + getTileFilename(tileX, tileY) + "'"); return raster; }
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()); } }
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]); }
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]); }