BufferedImageAdapter extends PlanarImage { @Override public Raster getTile(int tileX, int tileY) { if (tileX != 0 || tileY != 0) { return null; } else { return image.getTile(tileX, tileY); } } BufferedImageAdapter(BufferedImage image); @Override Raster getTile(int tileX, int tileY); Raster getData(); Raster getData(Rectangle rect); WritableRaster copyData(WritableRaster raster);  }
@Test public void testBufferedImage() { BufferedImage bi = new BufferedImage(768, 768, BufferedImage.TYPE_4BYTE_ABGR); BufferedImageAdapter adapter = new BufferedImageAdapter(bi); assertEquals(0, adapter.getMinX()); assertEquals(0, adapter.getMinY()); assertEquals(0, adapter.getMinTileX()); assertEquals(0, adapter.getMinTileY()); assertEquals(0, adapter.getTileGridXOffset()); assertEquals(0, adapter.getTileGridYOffset()); RenderedOp op = BandSelectDescriptor.create(adapter, new int[1], null); assertSame(adapter, op.getSourceObject(0)); assertNotNull(op.getTile(op.getMinTileX(), op.getMinTileY())); }
@Test public void testSubimage() { BufferedImage bi = new BufferedImage(768, 768, BufferedImage.TYPE_4BYTE_ABGR); BufferedImage subimage = bi.getSubimage(0, 512, 256, 256); BufferedImageAdapter adapter = new BufferedImageAdapter(subimage); assertEquals(0, adapter.getMinX()); assertEquals(0, adapter.getMinY()); assertEquals(0, adapter.getMinTileX()); assertEquals(0, adapter.getMinTileY()); assertEquals(0, adapter.getTileGridXOffset()); assertEquals(0, adapter.getTileGridYOffset()); RenderedOp op = BandSelectDescriptor.create(adapter, new int[1], null); assertSame(adapter, op.getSourceObject(0)); assertNotNull(op.getTile(op.getMinTileX(), op.getMinTileY())); }