Java Code Examples for java.awt.image.Raster#createRaster()
The following examples show how to use
java.awt.image.Raster#createRaster() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RasterOpNullDestinationRasterTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) { byte[][] data = new byte[1][10]; ByteLookupTable lut = new ByteLookupTable(0, data); RasterOp op = new LookupOp(lut, null); int[] bandOffsets = {0}; Point location = new Point(0, 0); DataBuffer db = new DataBufferByte(10 * 10); SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, 10, 10, 1, 10, bandOffsets); Raster src = Raster.createRaster(sm, db, location); op.filter(src, null); // this used to result in NullPointerException }
Example 2
Source File: Picture.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
private void updateParams () throws ImageFormatException { checkImageFormat(); // Cache dimensions dimension = new Dimension(image.getWidth(), image.getHeight()); raster = Raster.createRaster( image.getData().getSampleModel(), image.getData().getDataBuffer(), null); logger.debug("raster={}", raster); // Check pixel size and compute grayFactor accordingly ColorModel colorModel = image.getColorModel(); int pixelSize = colorModel.getPixelSize(); logger.debug("colorModel={} pixelSize={}", colorModel, pixelSize); if (pixelSize == 1) { grayFactor = 1; } else if (pixelSize <= 8) { grayFactor = (int) Math.rint(128 / Math.pow(2, pixelSize - 1)); } else if (pixelSize <= 16) { grayFactor = (int) Math.rint(32768 / Math.pow(2, pixelSize - 1)); } else { throw new RuntimeException("Unsupported pixel size: " + pixelSize); } logger.debug("grayFactor={}", grayFactor); }