public void setBytes( int x, int y, int width, int height, int band, byte[] values ) { if ( values != null && values.length >= ( width * height ) ) { ByteBuffer buf = getByteBuffer(); for ( int h = 0; h < height; h++ ) { for ( int w = 0; w < width; w++ ) { buf.put( calculatePos( x + w, y + h, band ), values[( 2 * h ) + w] ); } } } }
public void setDoubles( int x, int y, int width, int height, int band, double[] values ) { if ( values != null && values.length >= ( width * height ) ) { ByteBuffer buf = getByteBuffer(); for ( int h = 0; h < height; h++ ) { for ( int w = 0; w < width; w++ ) { buf.putDouble( calculatePos( x + w, y + h, band ), values[( 2 * h ) + w] ); } } } }
public void setInts( int x, int y, int width, int height, int band, int[] values ) { if ( values != null && values.length >= ( width * height ) ) { ByteBuffer buf = getByteBuffer(); for ( int h = 0; h < height; h++ ) { for ( int w = 0; w < width; w++ ) { buf.putInt( calculatePos( x + w, y + h, band ), values[( 2 * h ) + w] ); } } } }
public void setShorts( int x, int y, int width, int height, int band, short[] values ) { if ( values != null && values.length >= ( width * height ) ) { ByteBuffer buf = getByteBuffer(); for ( int h = 0; h < height; h++ ) { for ( int w = 0; w < width; w++ ) { buf.putShort( calculatePos( x + w, y + h, band ), values[( 2 * h ) + w] ); } } } }
public void setFloats( int x, int y, int width, int height, int band, float[] values ) { if ( values != null && values.length >= ( width * height ) ) { ByteBuffer buf = getByteBuffer(); for ( int h = 0; h < height; h++ ) { for ( int w = 0; w < width; w++ ) { buf.putFloat( calculatePos( x + w, y + h, band ), values[( 2 * h ) + w] ); } } } }
public void setByteSample( int x, int y, int band, byte value ) { getByteBuffer().put( calculatePos( x, y, band ), value ); }
public void setFloatPixel( int x, int y, float[] pixel ) { ByteBuffer buf = getByteBuffer(); for ( int band = 0; band < getView().dataInfo.bands; band++ ) { buf.putFloat( calculatePos( x, y, band ), pixel[band] ); } }
@Override public BufferResult read( RasterRect rect, ByteBuffer buffer ) throws IOException { // rb: not very optimized yet.. BufferedReader reader = new BufferedReader( new FileReader( this.file ) ); ByteBufferRasterData grid = readASCIIGrid( reader, null ); reader.close(); ByteBufferRasterData subset = grid.getSubset( rect ); return new BufferResult( rect, subset.getByteBuffer() ); }
public void setBytePixel( int x, int y, byte[] pixel ) { ByteBuffer buf = getByteBuffer(); for ( int band = 0; band < getView().dataInfo.bands; band++ ) { buf.put( calculatePos( x, y, band ), pixel[band] ); } }
public void setShortPixel( int x, int y, short[] pixel ) { ByteBuffer buf = getByteBuffer(); for ( int band = 0; band < getView().dataInfo.bands; band++ ) { buf.putShort( calculatePos( x, y, band ), pixel[band] ); } }
@Override public RasterData asReadOnly() { ByteBufferRasterData copy = createCompatibleEmptyRasterData(); copy.info = info; // this instantiation ensures a readonly buffer. copy.setByteBuffer( this.getByteBuffer().asReadOnlyBuffer(), null ); return copy; }
public void setDoublePixel( int x, int y, double[] pixel ) { ByteBuffer buf = getByteBuffer(); for ( int band = 0; band < getView().dataInfo.bands; band++ ) { buf.putDouble( calculatePos( x, y, band ), pixel[band] ); } }
public void setIntPixel( int x, int y, int[] pixel ) { ByteBuffer buf = getByteBuffer(); for ( int band = 0; band < getView().dataInfo.bands; band++ ) { buf.putInt( calculatePos( x, y, band ), pixel[band] ); } }
public void setSample( int x, int y, int band, byte[] value ) { if ( value == null || value.length < getView().dataInfo.dataSize ) { return; } ByteBuffer buf = getByteBuffer(); buf.position( calculatePos( x, y, band ) ); buf.put( value, 0, getView().dataInfo.dataSize ); }
public double getDoubleSample( int x, int y, int band ) { int pos = calculatePos( x, y, band ); if ( pos == -1 ) {// the position is outside the databuffer. ByteBuffer wrap = ByteBuffer.wrap( getView().dataInfo.noDataPixel ); return wrap.getDouble( getView().getBandOffset( band ) * getView().dataInfo.dataSize ); } return getByteBuffer().getDouble( pos ); }
public float getFloatSample( int x, int y, int band ) { int pos = calculatePos( x, y, band ); if ( pos == -1 ) {// the position is outside the databuffer. ByteBuffer wrap = ByteBuffer.wrap( getView().dataInfo.noDataPixel ); return wrap.getFloat( getView().getBandOffset( band ) * getView().dataInfo.dataSize ); } return getByteBuffer().getFloat( pos ); // return data.getFloat( calculatePos( x, y, band ) ); }
public int getIntSample( int x, int y, int band ) { int pos = calculatePos( x, y, band ); if ( pos == -1 ) {// the position is outside the databuffer. ByteBuffer wrap = ByteBuffer.wrap( getView().dataInfo.noDataPixel ); return wrap.getInt( getView().getBandOffset( band ) * getView().dataInfo.dataSize ); } return getByteBuffer().getInt( pos ); // return data.getInt( calculatePos( x, y, band ) ); }
public byte getByteSample( int x, int y, int band ) { int pos = calculatePos( x, y, band ); if ( pos == -1 ) {// the position is outside the databuffer. return getView().dataInfo.noDataPixel[getView().getBandOffset( band )]; } return getByteBuffer().get( pos ); }
public void setPixel( int x, int y, byte[] result ) { // operates on the view if ( result != null && result.length == ( getView().dataInfo.dataSize * getView().dataInfo.bands ) ) { int sampleSize = getView().dataInfo.dataSize; ByteBuffer buf = getByteBuffer(); for ( int b = 0; b < getView().dataInfo.bands; b++ ) { buf.position( calculatePos( x, y, b ) ); buf.put( result, b * sampleSize, sampleSize ); } } }
/** * @param reader * @param nOpts * @throws IOException */ private SimpleRaster createSimpleRaster( BufferedReader reader, RasterIOOptions nOpts ) throws IOException { ByteBufferRasterData data = readASCIIGrid( reader, nOpts ); ByteBuffer byteBuffer = data.getByteBuffer(); data = RasterDataFactory.createRasterData( width, height, data.getDataInfo(), geoReference, byteBuffer, true, FileUtils.getFilename( this.file ), nOpts ); SimpleRaster simpleRaster = new SimpleRaster( data, this.envelope, geoReference, null ); return simpleRaster; }