RasterFactory.createPixelInterleavedSampleModel( DataBuffer.TYPE_FLOAT, image.getWidth(), image.getHeight(), 1); TiledImage destImage =
RasterFactory.createPixelInterleavedSampleModel( DataBuffer.TYPE_INT, image.getWidth(), image.getHeight(), 1);
private ImageLayout buildLayout(Rectangle bounds, Dimension tileSize, int dataType) { if (bounds == null) { throw new IllegalStateException( "Cannot determine output image layout, dest bounds have not been provided"); } ImageLayout layout = new ImageLayout(bounds.x, bounds.y, bounds.width, bounds.height); SampleModel sm = RasterFactory.createPixelInterleavedSampleModel( dataType, tileSize.width, tileSize.height, 1); layout.setSampleModel(sm); layout.setColorModel(PlanarImage.createColorModel(sm)); return layout; }
private ImageLayout buildLayout(Rectangle bounds, Dimension tileSize, int dataType) { if (bounds == null) { throw new IllegalStateException( "Cannot determine output image layout, dest bounds have not been provided"); } ImageLayout layout = new ImageLayout(bounds.x, bounds.y, bounds.width, bounds.height); SampleModel sm = RasterFactory.createPixelInterleavedSampleModel( dataType, tileSize.width, tileSize.height, 1); layout.setSampleModel(sm); layout.setColorModel(PlanarImage.createColorModel(sm)); return layout; }
private static ImageLayout createTwoBandedImageLayout(int width, int height, Dimension tileSize) { if (width < 0) { throw new IllegalArgumentException("width"); } if (height < 0) { throw new IllegalArgumentException("height"); } if (tileSize == null) { throw new IllegalArgumentException("tileSize"); } SampleModel sampleModel = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_FLOAT, tileSize.width, tileSize.height, 2); ColorModel colorModel = PlanarImage.createColorModel(sampleModel); if (colorModel == null) { final int dataType = sampleModel.getDataType(); ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); int[] nBits = {DataBuffer.getDataTypeSize(dataType)}; colorModel = new ComponentColorModel(cs, nBits, false, true, Transparency.OPAQUE, dataType); } return new ImageLayout(0, 0, width, height, 0, 0, tileSize.width, tileSize.height, sampleModel, colorModel); }
private static ImageLayout createTwoBandedImageLayout(int width, int height, Dimension tileSize) { if (width < 0) { throw new IllegalArgumentException("width"); } if (height < 0) { throw new IllegalArgumentException("height"); } if (tileSize == null) { throw new IllegalArgumentException("tileSize"); } SampleModel sampleModel = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_FLOAT, tileSize.width, tileSize.height, 2); ColorModel colorModel = PlanarImage.createColorModel(sampleModel); if (colorModel == null) { final int dataType = sampleModel.getDataType(); ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); int[] nBits = {DataBuffer.getDataTypeSize(dataType)}; colorModel = new ComponentColorModel(cs, nBits, false, true, Transparency.OPAQUE, dataType); } return new ImageLayout(0, 0, width, height, 0, 0, tileSize.width, tileSize.height, sampleModel, colorModel); }
SampleModel sm = RasterFactory.createPixelInterleavedSampleModel( dataType, tileWidth, tileHeight, numBands);
SampleModel sm = RasterFactory.createPixelInterleavedSampleModel( dataType, tileWidth, tileHeight, numBands);
SampleModel sm = RasterFactory.createPixelInterleavedSampleModel( dataType, tileWidth, tileHeight, numBands);
int numYTiles = image.getNumYTiles(); SampleModel sm = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_FLOAT, image.getWidth(), image.getHeight(), 1); TiledImage destImage = new TiledImage(0, 0, image.getWidth(), image.getHeight(), 0, 0, sm, new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY),
SampleModel sm = RasterFactory.createPixelInterleavedSampleModel( dataType, tileWidth, tileHeight, numBands);
/** * Takes the 4-band ARGB image that we have been drawing into and * converts it to a single-band int image. */ private void flattenImageToInt() { int numXTiles = image.getNumXTiles(); int numYTiles = image.getNumYTiles(); SampleModel sm = RasterFactory.createPixelInterleavedSampleModel( DataBuffer.TYPE_INT, image.getWidth(), image.getHeight(), 1); TiledImage destImage = new TiledImage(0, 0, image.getWidth(), image.getHeight(), 0, 0, sm, new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_INT)); for (int yt = 0; yt < numYTiles; yt++) { for (int xt = 0; xt < numXTiles; xt++) { Raster srcTile = image.getTile(xt, yt); WritableRaster destTile = destImage.getWritableTile(xt, yt); int[] data = new int[srcTile.getDataBuffer().getSize()]; srcTile.getDataElements(srcTile.getMinX(), srcTile.getMinY(), srcTile.getWidth(), srcTile.getHeight(), data); Rectangle bounds = destTile.getBounds(); destTile.setPixels(bounds.x, bounds.y, bounds.width, bounds.height, data); destImage.releaseWritableTile(xt, yt); } } image = destImage; }
break; case INTEGER: sm = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_INT, dmImage.getTileWidth(), dmImage.getTileHeight(), 1); scs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
break; case INTEGER: sm = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_INT, dmImage.getTileWidth(), dmImage.getTileHeight(), 1); scs = ColorSpace.getInstance(ColorSpace.CS_GRAY);