private Converter(int width, int height) { this.scanlineStride = width * pixelStride; this.sampleModel = new ComponentSampleModel(dataType, width, height, pixelStride, scanlineStride, bgrBandOffsets); }
ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_BYTE, width, height, 3, width * 3, new int[] {0, 1, 2}); this.grid = Raster.createWritableRaster(sampleModel, videoBuffer, null); ColorModel colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
smodel = new ComponentSampleModel(DATA_TYPE, size.width, size.height, 3, size.width * 3, BAND_OFFSETS); cmodel = new ComponentColorModel(COLOR_SPACE, BITS, false, false, Transparency.OPAQUE, DATA_TYPE);
new ComponentSampleModel(dataType, width, height, 1, width, new int[] {0});
@Override public WritableRaster createCompatibleWritableRaster(int w, int h) { int[] bandOffsets = new int[nChannels]; for (int i=0; i<nChannels; i++) bandOffsets[i] = i; SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT, w, h, nChannels, w * nChannels, bandOffsets); DataBuffer db = new DataBufferInt(w * h, nChannels); return Raster.createWritableRaster(m, db, null); }
@Override public WritableRaster createCompatibleWritableRaster(int w, int h) { int[] bandOffsets = new int[nChannels]; for (int i=0; i<nChannels; i++) bandOffsets[i] = i; SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT, w, h, nChannels, w * nChannels, bandOffsets); DataBuffer db = new DataBufferInt(w * h, nChannels); return Raster.createWritableRaster(m, db, null); }
@Override public WritableRaster createCompatibleWritableRaster(final int w, final int h) { final int[] bandOffsets = new int[nChannels]; for (int i = 0; i < nChannels; i++) bandOffsets[i] = i; final SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT, w, h, nChannels, w * nChannels, bandOffsets); final DataBuffer db = new DataBufferInt(w * h, nChannels); return Raster.createWritableRaster(m, db, null); }
@Override public WritableRaster createCompatibleWritableRaster(int w, int h) { int[] bandOffsets = new int[nChannels]; for (int i=0; i<nChannels; i++) bandOffsets[i] = i; SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT, w, h, nChannels, w * nChannels, bandOffsets); DataBuffer db = new DataBufferInt(w * h, nChannels); return Raster.createWritableRaster(m, db, null); }
@Override public WritableRaster createCompatibleWritableRaster(final int w, final int h) { final int[] bandOffsets = new int[nChannels]; for (int i = 0; i < nChannels; i++) bandOffsets[i] = i; final SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT, w, h, nChannels, w * nChannels, bandOffsets); final DataBuffer db = new DataBufferInt(w * h, nChannels); return Raster.createWritableRaster(m, db, null); }
@Override public WritableRaster createCompatibleWritableRaster(int w, int h) { if (pixelBits == 16) { int[] bandOffsets = new int[nChannels]; for (int i=0; i<nChannels; i++) bandOffsets[i] = i; SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_SHORT, w, h, nChannels, w * nChannels, bandOffsets); DataBuffer db = new DataBufferShort(w * h, nChannels); return Raster.createWritableRaster(m, db, null); } return helper.createCompatibleWritableRaster(w, h); }
@Override public WritableRaster createCompatibleWritableRaster(int w, int h) { if (pixelBits == 16) { int[] bandOffsets = new int[nChannels]; for (int i=0; i<nChannels; i++) bandOffsets[i] = i; SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_SHORT, w, h, nChannels, w * nChannels, bandOffsets); DataBuffer db = new DataBufferShort(w * h, nChannels); return Raster.createWritableRaster(m, db, null); } return helper.createCompatibleWritableRaster(w, h); }
@Override public WritableRaster createCompatibleWritableRaster(final int w, final int h) { if (pixelBits == 16) { final int[] bandOffsets = new int[nChannels]; for (int i = 0; i < nChannels; i++) bandOffsets[i] = i; final SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_SHORT, w, h, nChannels, w * nChannels, bandOffsets); final DataBuffer db = new DataBufferShort(w * h, nChannels); return Raster.createWritableRaster(m, db, null); } return helper.createCompatibleWritableRaster(w, h); }
@Override public WritableRaster createCompatibleWritableRaster(final int w, final int h) { if (pixelBits == 16) { final int[] bandOffsets = new int[nChannels]; for (int i = 0; i < nChannels; i++) bandOffsets[i] = i; final SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_SHORT, w, h, nChannels, w * nChannels, bandOffsets); final DataBuffer db = new DataBufferShort(w * h, nChannels); return Raster.createWritableRaster(m, db, null); } return helper.createCompatibleWritableRaster(w, h); }
/** Simple method for image creation */ public static RenderedImage createTestImage(int dataType, int width, int height, Number noDataValue, boolean isBinary, int numBands, Number validData) { final SampleModel sm; if (isBinary) { // Binary images Sample Model sm = new MultiPixelPackedSampleModel(dataType, width, height, 1); numBands = 1; } else { int imageDim = width * height; if(numBands == 3){ sm = new ComponentSampleModel(dataType, width, height, 3, width, new int[] { 0, imageDim, imageDim * 2 }); }else{ sm = new ComponentSampleModel(dataType, width, height, 1, width, new int[] {0}); } } return createTestImage(width, height, noDataValue, numBands, validData, sm); }
private static TiledImage createImage(int dataType, int value) { SampleModel sm = new ComponentSampleModel(dataType, DEFAULT_WIDTH, DEFAULT_HEIGHT, 1, DEFAULT_WIDTH, new int[] { 0 }); TiledImage image = new TiledImage(sm, DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT); int minX = 10; int maxX = 20; int minY = 10; int maxY = 20; for (int x = minX; x < maxX; x++) { for (int y = minY; y < maxY; y++) { image.setSample(x, y, 0, value); } } return image; }
= new ComponentSampleModel( DataBuffer.TYPE_BYTE, w, h, 4, bytesPerRow,
Number noDataValue) { final SampleModel sm = new ComponentSampleModel(dataType, width, height, 1, width, new int[] {0}); ColorModel cm = TiledImage.createColorModel(sm); if(cm == null) {
/** * Build a 4x4 image with pixels having value as the sum of their coordinates, attaches * a ROI covering the 4 central pixels, and scales up by a factor of 2 with the given interpolation * @param dataType * @return */ protected RenderedImage buildImageWithROI(int dataType, Interpolation interpolation, boolean useROIAccessor, Range noData) { int width = 4; int height = 4; SampleModel sm = new ComponentSampleModel(dataType, width, height, 1, width, new int[] {0}); TiledImage source = new TiledImage(0, 0, width, height, 0, 0, sm, PlanarImage.createColorModel(sm)); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { source.setSample(x, y, 0, x + y); } } // build a ROI covering the center of the image and associate ROI roi = new ROIShape(new Rectangle(1, 1, 2, 2)); RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,BorderExtender.createInstance(BorderExtender.BORDER_COPY)); hints.put(JAI.KEY_IMAGE_LAYOUT, new ImageLayout(0, 0, width * 2, height * 2, 0, 0, width * 2, height * 2, null, null)); return ScaleDescriptor.create(source, 2f, 2f, 0f, 0f, interpolation, roi, useROIAccessor, noData, new double[] {0}, hints); }
/** * Build a 4x4 image with pixels having value as the sum of their coordinates, attaches * a ROI covering the 4 central pixels, and scales up by a factor of 2 with the given interpolation * @param dataType * @return */ protected RenderedImage buildImageWithROI(int dataType, Interpolation interpolation, boolean useROIAccessor, Range noData) { int width = 4; int height = 4; SampleModel sm = new ComponentSampleModel(dataType, width, height, 1, width, new int[] {0}); TiledImage source = new TiledImage(0, 0, width, height, 0, 0, sm, PlanarImage.createColorModel(sm)); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { source.setSample(x, y, 0, x + y); } } // build a ROI covering the center of the image and associate ROI roi = new ROIShape(new Rectangle(1, 1, 2, 2)); RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,BorderExtender.createInstance(BorderExtender.BORDER_COPY)); hints.put(JAI.KEY_IMAGE_LAYOUT, new ImageLayout(0, 0, width * 2, height * 2, 0, 0, width * 2, height * 2, null, null)); return Scale2Descriptor.create(source, 2d, 2d, 0d, 0d, interpolation, roi, useROIAccessor, noData, new double[] {0}, hints); } }
@Test public void testPlanarImageTranslatedChild() throws Exception { SampleModel sm = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 128, 128, 1, 128, new int[] {0}); TiledImage source = new TiledImage(0, 0, 512, 512, 0, 0, sm, PlanarImage.createColorModel(sm)); Raster[] tiles = source.getTiles(); assertEquals(16, tiles.length); // Without fix for GEOS-8137, this split call will cause a // java.lang.ClassCastException: java.awt.image.Raster cannot be cast to // java.awt.image.WritableRaster MetatileMapOutputFormat.split(key, source); } }