## javax.media.j3d
Class NioImageBuffer

    java.lang.Object
      javax.media.j3d.NioImageBuffer

    public class NioImageBuffer

extends java.lang.Object

The NioImageBuffer class is a container for an image whose DataBuffer is specified via a java.nio.Buffer. An an NioImageBuffer can be wrapped by an ImageComponent and used for texture mapping, or for rendering Raster objects or background images. An NioImageBuffer must not be used as the buffer of an off-screen Canvas3D, or for reading back a raster image.

Since:
  Java 3D 1.5
See Also:
  `ImageComponent2D`, `ImageComponent3D`

Nested Class Summary
`static class` `NioImageBuffer.ImageType` Used to specify the type of the image.

Constructor Summary
`NioImageBuffer(int width, int height, NioImageBuffer.ImageType imageType)` Constructs an NIO image buffer of the specified size and type.
`NioImageBuffer(int width, int height, NioImageBuffer.ImageType imageType, java.nio.Buffer dataBuffer)` Constructs an NIO image buffer of the specified size and type, using the specified dataBuffer.

Method Summary
`java.nio.Buffer` `getDataBuffer()` Gets the data buffer to the specified input data buffer.
`int` `getHeight()` Gets the height of this data buffer.
`NioImageBuffer.ImageType` `getImageType()` Gets the image type of this data buffer.
`int` `getWidth()` Gets the width of this data buffer.
`void` `setDataBuffer(java.nio.Buffer dataBuffer)` Sets the data buffer to the specified input data buffer.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### NioImageBuffer

    public NioImageBuffer(int width,
                          int height,
                          NioImageBuffer.ImageType imageType)

  Constructs an NIO image buffer of the specified size and type. A direct NIO buffer of the correct type (ByteBuffer or IntBuffer) and size to match the input parameters is allocated.

  Parameters:
    `width` - width of the image
    `height` - height of the image
    `imageType` - type of the image.
  Throws:
    `java.lang.IllegalArgumentException` - if width < 1 or height < 1
    `java.lang.NullPointerException` - if imageType is null

### NioImageBuffer

    public NioImageBuffer(int width,
                          int height,
                          NioImageBuffer.ImageType imageType,
                          java.nio.Buffer dataBuffer)

  Constructs an NIO image buffer of the specified size and type, using the specified dataBuffer. The the byte order of the specified dataBuffer must match the native byte order of the underlying platform. For best performance, the NIO buffer should be a direct buffer.

  Parameters:
    `width` - width of the image
    `height` - height of the image
    `imageType` - type of the image.
    `dataBuffer` - an NIO buffer of the correct type (ByteBuffer or IntBuffer) to match the specified imageType. This constructor will create a new view of the buffer, and will call `rewind` on that view, such that elements 0 through `dataBuffer.limit()-1` will be available internally. The number of elements in the buffer must be exactly `width*height*numElementsPerPixel`, where `numElementsPerPixel` is 3 for TYPE_3BYTE_BGR and TYPE_3BYTE_RGB, 4 for TYPE_4BYTE_ABGR and TYPE_4BYTE_RGBA, and 1 for all other types.
  Throws:
    `java.lang.IllegalArgumentException` - if width < 1 or height < 1
    `java.lang.NullPointerException` - if imageType or dataBuffer is null
    `java.lang.IllegalArgumentException` - if the type of the dataBuffer does not match the imageType
    `java.lang.IllegalArgumentException` - if `dataBuffer.limit() != width*height*numElementsPerPixel`
    `java.lang.IllegalArgumentException` - if the byte order of the specified dataBuffer does not match the native byte order of the underlying platform.

Method Detail

### getWidth

    public int getWidth()

  Gets the width of this data buffer.

  Returns:
    the width of this data buffer.

### getHeight

    public int getHeight()

  Gets the height of this data buffer.

  Returns:
    the width of this data buffer.

### getImageType

    public NioImageBuffer.ImageType getImageType()

  Gets the image type of this data buffer.

  Returns:
    the image type of this data buffer.

### setDataBuffer

    public void setDataBuffer(java.nio.Buffer dataBuffer)

  Sets the data buffer to the specified input data buffer. The the byte order of the specified dataBuffer must match the native byte order of the underlying platform. For best performance, the NIO buffer should be a direct buffer.

  Parameters:
    `dataBuffer` - an NIO buffer of the correct type (ByteBuffer or IntBuffer) to match the imageType of this NioImageBuffer. This method will create a new view of the buffer, and will call `rewind` on that view, such that elements 0 through `dataBuffer.limit()-1` will be available internally. The number of elements in the buffer must be exactly `width*height*numElementsPerPixel`, where `numElementsPerPixel` is 3 for TYPE_3BYTE_BGR and TYPE_3BYTE_RGB, 4 for TYPE_4BYTE_ABGR and TYPE_4BYTE_RGBA, and 1 for all other types.
  Throws:
    `java.lang.NullPointerException` - if dataBuffer is null
    `java.lang.IllegalArgumentException` - if the type of the dataBuffer does not match the imageType
    `java.lang.IllegalArgumentException` - if `dataBuffer.limit() != width*height*numElementsPerPixel`
    `java.lang.IllegalArgumentException` - if the byte order of the specified dataBuffer does not match the native byte order of the underlying platform.

### getDataBuffer

    public java.nio.Buffer getDataBuffer()

  Gets the data buffer to the specified input data buffer.

  Returns:
    a view of the current data buffer for this NIO image buffer. This view will be rewound such that elements 0 through `dataBuffer.limit()-1` are available.

Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.