private void readUncompressedIntegerRowByNumber ( ByteBuffer rowdata , int rn , RandomAccessFile thefile ) throws IOException , DataFormatException { int cellValue = 0 ; ByteBuffer cell = ByteBuffer . allocate ( rasterMapType ) ; /* The number of bytes that are inside a row in the file. */ int filerowsize = fileWindow . getCols ( ) * rasterMapType ; /* Position the file pointer to read the row */ thefile . seek ( ( rn * filerowsize ) ) ; /* Read the row of data from the file */ ByteBuffer tmpBuffer = ByteBuffer . allocate ( filerowsize ) ; thefile . read ( tmpBuffer . array ( ) ) ; /* * Transform the rasterMapType-size-values to a standard 4 bytes integer value */ while ( tmpBuffer . hasRemaining ( ) ) { // read the value tmpBuffer . get ( cell . array ( ) ) ; /* * Integers can be of 1, 2, or 4 bytes. As rasterBuffer expects 4 byte integers we need * to pad them with 0's. The order of the padding is determined by the ByteOrder of the * buffer. */ if ( rasterMapType == 1 ) { cellValue = ( cell . get ( 0 ) & 0xff ) ; } else if ( rasterMapType == 2 ) { cellValue = cell . getShort ( 0 ) ; } else if ( rasterMapType == 4 ) { cellValue = cell . getInt ( 0 ) ; } // if (logger.isDebugEnabled()) logger.debug("tmpint=" + cellValue // ); rowdata . putInt ( cellValue ) ; } }
read a row of data from an uncompressed integer map