code: public ByteBuffer interpolateColorMap( int mapType, ByteBuffer data, int dataOffset ) {
          int dataLength = data.capacity() - dataOffset;
          /* Allocate colour map output buffer using 4 bytes per cell value (RGBA) */
          ByteBuffer cmapBuffer = ByteBuffer.allocate(dataLength);
  
          /* Set buffer position */
          data.position(dataOffset);
  
          if (mapType > 0) {
              while( data.hasRemaining() ) {
                  /*
                   * For each value in the array get the index from the rules map and then translate
                   * the rule.
                   */
                  int f = data.getInt();
  
                  cmapBuffer.put(f == Integer.MAX_VALUE ? blank : getColor((float) f));
              }
          } else if (mapType == -1) {
              while( data.hasRemaining() ) {
                  /*
                   * For each value in the array get the index from the rules map and then translate
                   * the rule.
                   */
                  float f = data.getFloat();
                  cmapBuffer.put(Float.isNaN(f) ? blank : getColor(f));
              }
          } else if (mapType == -2) {
              while( data.hasRemaining() ) {
                  /*
                   * For each value in the array get the index from the rules map and then translate
                   * the rule.
                   */
                  float f = (float) data.getDouble();
                  cmapBuffer.put(Float.isNaN(f) ? blank : getColor(f));
  
                  // if (!Float.isNaN(f) && f > 0)
                  // System.out.println("COLOR-TABLE->" + f + " has color "
                  // + (Float.isNaN(f) ? blank : getColor(f)));
  
                  /*
                   * test the data map
                   */
                  /*
                   * System.out.print(f + " "); if (counter == 1024) { System.out.println(); counter =
                   * 1; } else { counter++; }
                   */
  
              }
          }
          return cmapBuffer;
      }
docs: Create the buffer with the rbg colormap.
  
  @param mapType - type of map, from which to understand the single value offset
  @param data - the buffer with the data
  @param dataOffset - offset to define rows
  @return the colormap byte buffer