@Override public String toString() { StringBuilder result = new StringBuilder(); result.append( "RasterData: type " + dataInfo.dataType + ", " ); result.append( "size " + getOriginalWidth() + "x" + getOriginalHeight() ); result.append( ", interleaving " + dataInfo.interleaveType ); return result.toString(); }
public byte[] getPixel( int x, int y, byte[] result ) { // operates on the getView(). int numBands = getView().dataInfo.bands; // datasize should be equal between original data and the view int sampleSize = getView().dataInfo.dataSize; if ( result == null || result.length < ( numBands * sampleSize ) ) { result = new byte[numBands * sampleSize]; } // null pixel if ( 0 > x || x >= getOriginalWidth() || 0 > y || y >= getOriginalHeight() ) { System.arraycopy( getView().dataInfo.noDataPixel, 0, result, 0, result.length ); return result; } // copy per band on the getView(). for ( int b = 0; b < numBands; b++ ) { int pos = calculatePos( x, y, b ); if ( pos == -1 ) {// the position is outside the databuffer. System.arraycopy( getView().dataInfo.noDataPixel, b * sampleSize, result, b * sampleSize, sampleSize ); } else { ByteBuffer buf = getByteBuffer(); buf.position( pos ); buf.get( result, b * sampleSize, sampleSize ); } } return result; }
/** * Checks whether a given rect is inside the raster. * * @param x * The x position of the rect. * @param y * The y position of the rect. * @param width * The width of the rect. * @param height * The height of the rect. * @return <code>true</code> if the given rect is inside the raster, else <code>false</code> */ protected final boolean checkBounds( int x, int y, int width, int height ) { if ( ( ( getView().x + x + width ) > this.getOriginalWidth() ) || ( ( getView().y + y + height ) > this.getOriginalHeight() ) || ( getView().x + x < 0 ) || ( getView().y + y < 0 ) ) { return false; } return true; }
public ByteBufferRasterData getSubset( RasterRect sampleDomain, BandType[] bands ) { int newOrigx = min( getView().x + sampleDomain.x, getOriginalWidth() ); int newOrigy = min( getView().y + sampleDomain.y, getOriginalHeight() );