final SampleModel sampleModel = sourceImage.getSampleModel(); final int sourceTileW = sampleModel.getWidth(); final int sourceTileH = sampleModel.getHeight(); final Dimension tileDimensions = new Dimension(sourceTileW, sourceTileH); LOGGER.fine("Source tiling:" + tileDimensions.width + "x" + tileDimensions.height);
originalSampleModel.getDataType(), originalSampleModel.getWidth(), originalSampleModel.getHeight(), coverageView.getCoverageBands().size()); layout.getMinY(null), originalSampleModel.getWidth(), originalSampleModel.getHeight()); imageLayout.setSampleModel(sampleModel); imageLayout.setColorModel(colorModel);
private WritableRaster buildSolidRaster(int tileWidth, int tileHeight, int value) { SampleModel sampleModel = getMPSampleModel(tileWidth, tileHeight); // build the raster WritableRaster newRaster = RasterFactory.createWritableRaster(sampleModel, new java.awt.Point(0, 0)); // sanity checks int dataType = sampleModel.getTransferType(); int numBands = sampleModel.getNumBands(); if (dataType != DataBuffer.TYPE_BYTE) { throw new IllegalArgumentException( "The code works only if the sample model data type is BYTE"); } if (numBands != 1) { throw new IllegalArgumentException("The code works only for single band rasters!"); } if (value != 0) { // flood fill int w = sampleModel.getWidth(); int h = sampleModel.getHeight(); int[] data = new int[w * h]; Arrays.fill(data, value); newRaster.setSamples(0, 0, w, h, 0, data); } return newRaster; }
public NetCDFImageMetadata( String variableName, SampleModel sm, ColorModel cm, CoordinateReferenceSystem crs) { super(true, nativeMetadataFormatName, nativeMetadataFormatClassName, null, null); setDatasetName(variableName); // width and height, tile structure assuming row based setWidth(sm.getWidth()); setHeight(sm.getHeight()); setTileWidth(sm.getWidth()); setTileHeight(1); // color and sample models and information coming from them setColorModel(cm); setSampleModel(sm); setNumBands(sm.getNumBands()); try { if (crs != null) { // attempt to set projection description setProjection(crs.getIdentifiers().iterator().next().toString()); } } catch (Exception e) { LOGGER.log(Level.FINE, "Could not add the projection information into the metadata", e); } } }
final SampleModel destinationSampleModel = destinationColorModel.createCompatibleSampleModel( sampleModel.getWidth(), sampleModel.getHeight()); ImageLayout layout = new ImageLayout(image); layout.setColorModel(destinationColorModel);
@Test public void testCreateCompatibleSampleModel() { int[] colors = createIntLut(1 << 8); IndexColorModel icm = new IndexColorModel(8, colors.length, colors, 0, false, -1, DataBuffer.TYPE_BYTE); ColorModel colorModel = new DiscreteAlphaIndexColorModel(icm); SampleModel sampleModel = colorModel.createCompatibleSampleModel(3, 2); assertNotNull(sampleModel); assertEquals(3, sampleModel.getWidth()); assertEquals(2, sampleModel.getHeight()); assertTrue(colorModel.isCompatibleSampleModel(sampleModel)); assertThat(sampleModel, CoreMatchers.is(PixelInterleavedSampleModel.class)); assertThat(sampleModel.getDataType(), CoreMatchers.equalTo(DataBuffer.TYPE_BYTE)); }
layout.setColorModel(cm); layout.setSampleModel( cm.createCompatibleSampleModel(oldSM.getWidth(), oldSM.getHeight())); hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout)); output =
@Test public void testCreateCompatibleSampleModelUShort() { int[] colors = createIntLut(1 << 8); IndexColorModel icm = new IndexColorModel(8, colors.length, colors, 0, false, -1, DataBuffer.TYPE_USHORT); ColorModel colorModel = new DiscreteAlphaIndexColorModel(icm); SampleModel sampleModel = colorModel.createCompatibleSampleModel(3, 2); assertNotNull(sampleModel); assertEquals(3, sampleModel.getWidth()); assertEquals(2, sampleModel.getHeight()); assertTrue(colorModel.isCompatibleSampleModel(sampleModel)); assertThat(sampleModel, CoreMatchers.is(PixelInterleavedSampleModel.class)); assertThat(sampleModel.getDataType(), CoreMatchers.equalTo(DataBuffer.TYPE_USHORT)); }
final int height = sampleModel.getHeight(); final int width = sampleModel.getWidth(); if (height * scaleFactor < 1) {
cm.getTransparency(), cm.getTransferType()); sm = cm.createCompatibleSampleModel(sm.getWidth(), sm.getHeight());
.setTileWidth(sampleModel.getHeight()); hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
public static SampleModel makeSampleModel(CachableRed cr, ColorModel cm) { SampleModel srcSM = cr.getSampleModel(); return cm.createCompatibleSampleModel(srcSM.getWidth(), srcSM.getHeight()); }
public static SampleModel makeSampleModel(CachableRed cr, ColorModel cm) { SampleModel srcSM = cr.getSampleModel(); return cm.createCompatibleSampleModel(srcSM.getWidth(), srcSM.getHeight()); }
public static SampleModel makeSampleModel(CachableRed cr, ColorModel cm) { SampleModel srcSM = cr.getSampleModel(); return cm.createCompatibleSampleModel(srcSM.getWidth(), srcSM.getHeight()); }
public static SampleModel makeSampleModel(CachableRed cr, ColorModel cm) { SampleModel srcSM = cr.getSampleModel(); return cm.createCompatibleSampleModel(srcSM.getWidth(), srcSM.getHeight()); }
public int getTileHeight(int imageIndex) throws IOException { checkIndex(imageIndex); return iis.getImageType().getSampleModel().getHeight(); }
private static void writeTo(SampleModel sm, byte[][] bankData, OutputStream out) throws IOException { int h = sm.getHeight(); int w = sm.getWidth(); ComponentSampleModel csm = (ComponentSampleModel) sm; int len = w * csm.getPixelStride(); int stride = csm.getScanlineStride(); if (csm.getBandOffsets()[0] != 0) bgr2rgb(bankData[0]); for (byte[] b : bankData) for (int y = 0, off = 0; y < h; ++y, off += stride) out.write(b, off, len); }
private void write(SampleModel sm, byte[][] bankData) throws IOException { int h = sm.getHeight(); int w = sm.getWidth(); ComponentSampleModel csm = (ComponentSampleModel) sm; int len = w * csm.getPixelStride(); int stride = csm.getScanlineStride(); if (csm.getBandOffsets()[0] != 0) bgr2rgb(bankData[0]); for (byte[] b : bankData) for (int y = 0, off = 0; y < h; ++y, off += stride) dos.write(b, off, len); }
public void testThatImageIsNotTiled() { assertEquals(1, imageFLOAT32.getTileCount()); assertEquals(IMAGE_W, imageFLOAT32.getSampleModel().getWidth()); assertEquals(IMAGE_H, imageFLOAT32.getSampleModel().getHeight()); }
public void testThatImageIsTiled() { assertEquals(TILE_SIZE, imageFLOAT32.getSampleModel().getWidth()); assertEquals(TILE_SIZE, imageFLOAT32.getSampleModel().getHeight()); assertEquals(4, imageFLOAT32.getTileCount()); }