List of usage examples for java.awt.image Raster getSampleModel
public SampleModel getSampleModel()
From source file:org.mrgeo.opimage.MrsPyramidOpImage.java
private static ImageLayout calculateLayout(final MrsImageDataProvider dp, final int zoomlevel) throws IOException { final MrsImagePyramidMetadata metadata = dp.getMetadataReader().read(); final LongRectangle pixelbounds = metadata.getPixelBounds(zoomlevel); MrsTileReader<Raster> tileReader = dp.getMrsTileReader(zoomlevel); final Iterator<Raster> it = tileReader.get(); Raster raster = it.next(); final ColorModel colorModel = RasterUtils.createColorModel(raster); final ImageLayout layout = new ImageLayout(0, 0, (int) pixelbounds.getWidth(), (int) pixelbounds.getHeight(), 0, 0, metadata.getTilesize(), metadata.getTilesize(), raster.getSampleModel(), colorModel); return layout; }
From source file:org.photovault.swingui.ImageTile.java
/** * Draws the tile if it is found in cache. Otherwise, schedule a request * for computing it./*from w w w.j a v a 2 s .c o m*/ * @param cache * @param g */ public void drawTile(TileCache cache, Graphics2D g) { Raster r = cache.getTile(img, tileX, tileY); if (r == null) { if (tileReq == null) { Point[] tileCoord = new Point[1]; tileCoord[0] = new Point(tileX, tileY); tileReq = img.queueTiles(tileCoord); } } else { DataBuffer buf = r.getDataBuffer(); SampleModel sm = r.getSampleModel(); WritableRaster wr = Raster.createWritableRaster(sm, buf, new Point(0, 0)); ColorModel cm = img.getColorModel(); BufferedImage bufImg = new BufferedImage(cm, wr, false, null); g.drawImage(bufImg, null, tileX * tileWidth, tileY * tileHeight); } }