Exemple #1
0
  /**
   * Gets the <i>i</i>th mipmap data (0..getNumMipMaps() - 1)
   *
   * @param side Cubemap side or 0 for 2D texture
   * @param map Mipmap index
   * @return Image object
   */
  public ImageInfo getMipMap(int side, int map) {
    if (!isCubemap() && (side != 0)) {
      throw new RuntimeException("Illegal side for 2D texture: " + side);
    }
    if (isCubemap() && !isCubemapSidePresent(side)) {
      throw new RuntimeException("Illegal side, side not present: " + side);
    }
    if (getNumMipMaps() > 0 && ((map < 0) || (map >= getNumMipMaps()))) {
      throw new RuntimeException(
          "Illegal mipmap number " + map + " (0.." + (getNumMipMaps() - 1) + ")");
    }

    // Figure out how far to seek
    int seek = Header.writtenSize();
    if (isCubemap()) {
      seek += sideShiftInBytes(side);
    }
    for (int i = 0; i < map; i++) {
      seek += mipMapSizeInBytes(i);
    }
    buf.limit(seek + mipMapSizeInBytes(map));
    buf.position(seek);
    ByteBuffer next = buf.slice();
    buf.position(0);
    buf.limit(buf.capacity());
    return new ImageInfo(
        next, mipMapWidth(map), mipMapHeight(map), isCompressed(), getCompressionFormat());
  }
Exemple #2
0
  public static void main(String args[]) throws Exception {
    ByteBuffer buffer = ByteBuffer.allocate(10);

    for (int i = 0; i < buffer.capacity(); ++i) {
      buffer.put((byte) i);
    }

    buffer.position(3);
    buffer.limit(7);

    ByteBuffer slice = buffer.slice();

    for (int i = 0; i < slice.capacity(); ++i) {
      byte b = slice.get(i);
      b *= 11;
      slice.put(i, b);
    }

    buffer.position(0);
    buffer.limit(buffer.capacity());

    while (buffer.hasRemaining()) {
      System.out.println(buffer.get());
    }
  }
 LockAndModify(ByteBuffer mbb, int start, int end) {
   this.start = start;
   this.end = end;
   mbb.limit(end);
   mbb.position(start);
   buff = mbb.slice();
   start();
 }