/** * Calculates the position of a pixel in a view (FloatBuffer, etc.) of the ByteBuffer. * * This method considers different sample sizes (eg. byte, float) and returns the position in sample strides (not * byte strides). Use this method to get proper positions for ByteBuffer views like FloatBuffer, ShortBuffer, etc.. * * @param x * x coordinate * @param y * y coordinate * @return offset to the pixel with the specified coordinates or -1 if outside of the bytebuffer. */ public final int calculateViewPos( int x, int y ) { int pos = calculatePos( x, y ) / dataInfo.dataSize; return pos < 0 ? -1 : pos; }
/** * Calculates the position of a pixel in the ByteBuffer. * * This method calculates the position of a pixel and returns the offset to this pixel in bytes. Use this method for * direct access to ByteBuffers. * * @param x * x coordinate * @param y * y coordinate * @return byte offset to the pixel with the specified coordinate or -1 if outside of the bytebuffer. */ public final int calculatePos( int x, int y ) { return dataAccess.calculatePos( x, y ); }
/** * Calculates the position of a sample in the ByteBuffer. * * This method calculates the position of a pixel and returns the offset to this pixel in bytes. Use this method for * direct access to ByteBuffers. * * @param x * x coordinate * @param y * y coordinate * @param bandOfView * band index of the sample * @return byte offset to the sample with the specified coordinate or -1 if outside of the bytebuffer. */ public final int calculatePos( int x, int y, int bandOfView ) { return dataAccess.calculatePos( x, y, bandOfView ); }
/** * Calculates the position of a sample in a view (FloatBuffer, etc.) of the ByteBuffer. * * This method considers different sample sizes (eg. byte, float) and returns the position in sample stides (not * byte strides). Use this method to get proper positions for ByteBuffer-views like FloatBuffer, ShortBuffer, etc.. * * @param x * x coordinate * @param y * y coordinate * @param band * band index of the sample * @return offset to the sample with the specified coordinates */ public final int calculateViewPos( int x, int y, int band ) { int pos = calculatePos( x, y, band ) / dataInfo.dataSize; return pos < 0 ? -1 : pos; }