/** Generate a tiled image that contains a view of the mask. */ @SuppressWarnings("restriction") public TiledImage getMaskImage() { TiledImage ti = new TiledImage( 0, 0, mwidth, mheight, 0, 0, new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE, mwidth, mheight, 1, mwidth, Transform.bandstride), new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, ComponentColorModel.OPAQUE, DataBuffer.TYPE_BYTE)); WritableRaster gradRaster = ti.getWritableTile(0, 0); DataBufferByte gradDB = (DataBufferByte) gradRaster.getDataBuffer(); byte[] gradImageData = gradDB.getData(); int maskwh = mwidth * mheight; for (int i = 0; i < maskwh; i++) gradImageData[i] = (byte) mask[i]; return ti; }