public class NioImageBuffer extends Object
ImageComponent2D
,
ImageComponent3D
Modifier and Type | Class and Description |
---|---|
static class |
NioImageBuffer.ImageType
Used to specify the type of the image.
|
Constructor and Description |
---|
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,
Buffer dataBuffer)
Constructs an NIO image buffer of the specified size and type, using
the specified dataBuffer.
|
Modifier and Type | Method and Description |
---|---|
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(Buffer dataBuffer)
Sets the data buffer to the specified input data buffer.
|
public NioImageBuffer(int width, int height, NioImageBuffer.ImageType imageType)
width
- width of the imageheight
- height of the imageimageType
- type of the image.IllegalArgumentException
- if width < 1 or height < 1NullPointerException
- if imageType is nullpublic NioImageBuffer(int width, int height, NioImageBuffer.ImageType imageType, Buffer dataBuffer)
width
- width of the imageheight
- height of the imageimageType
- 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.IllegalArgumentException
- if width < 1 or height < 1NullPointerException
- if imageType or dataBuffer is nullIllegalArgumentException
- if the type of the dataBuffer does
not match the imageTypeIllegalArgumentException
- if dataBuffer.limit() !=
width*height*numElementsPerPixel
IllegalArgumentException
- if the byte order of the specified
dataBuffer does not match the native byte order of the underlying
platform.public int getWidth()
public int getHeight()
public NioImageBuffer.ImageType getImageType()
public void setDataBuffer(Buffer dataBuffer)
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.NullPointerException
- if dataBuffer is nullIllegalArgumentException
- if the type of the dataBuffer does
not match the imageTypeIllegalArgumentException
- if dataBuffer.limit() !=
width*height*numElementsPerPixel
IllegalArgumentException
- if the byte order of the specified
dataBuffer does not match the native byte order of the underlying
platform.public Buffer getDataBuffer()
dataBuffer.limit()-1
are available.Copyright © 2016–2022 SciJava. All rights reserved.