public class ImageComponent2D extends ImageComponent
BufferedImage bi;
RenderedImage ri = bi;
ImageComponent2D ic;
// Set the image to the specified BufferedImage
ic.set(bi);
// Set the image to the specified RenderedImage
ic.set(ri);
As of Java 3D 1.5, an ImageComponent2D accepts an NioImageBuffer object as an alternative to a RenderedImage.
Modifier and Type | Class and Description |
---|---|
static interface |
ImageComponent2D.Updater
The ImageComponent2D.Updater interface is used in updating image data
that is accessed by reference from a live or compiled ImageComponent
object.
|
ImageComponent.ImageClass
ALLOW_FORMAT_READ, ALLOW_IMAGE_READ, ALLOW_IMAGE_WRITE, ALLOW_SIZE_READ, FORMAT_CHANNEL8, FORMAT_LUM4_ALPHA4, FORMAT_LUM8_ALPHA8, FORMAT_R3_G3_B2, FORMAT_RGB, FORMAT_RGB4, FORMAT_RGB5, FORMAT_RGB5_A1, FORMAT_RGB8, FORMAT_RGBA, FORMAT_RGBA4, FORMAT_RGBA8
Constructor and Description |
---|
ImageComponent2D(int format,
BufferedImage image)
Constructs a 2D image component object using the specified format
and BufferedImage.
|
ImageComponent2D(int format,
BufferedImage image,
boolean byReference,
boolean yUp)
Constructs a 2D image component object using the specified format,
BufferedImage, byReference flag, and yUp flag.
|
ImageComponent2D(int format,
int width,
int height)
Constructs a 2D image component object using the specified
format, width, and height.
|
ImageComponent2D(int format,
int width,
int height,
boolean byReference,
boolean yUp)
Constructs a 2D image component object using the specified
format, width, height, byReference flag, and yUp flag.
|
ImageComponent2D(int format,
NioImageBuffer image,
boolean byReference,
boolean yUp)
Constructs a 2D image component object using the specified format,
NioImageBuffer, byReference flag, and yUp flag.
|
ImageComponent2D(int format,
RenderedImage image)
Constructs a 2D image component object using the specified format
and RenderedImage.
|
ImageComponent2D(int format,
RenderedImage image,
boolean byReference,
boolean yUp)
Constructs a 2D image component object using the specified format,
RenderedImage, byReference flag, and yUp flag.
|
Modifier and Type | Method and Description |
---|---|
NodeComponent |
cloneNodeComponent()
Deprecated.
replaced with cloneNodeComponent(boolean forceDuplicate)
|
BufferedImage |
getImage()
Retrieves the image from this ImageComponent2D object.
|
NioImageBuffer |
getNioImage()
Retrieves the image from this ImageComponent2D object.
|
RenderedImage |
getRenderedImage()
Retrieves the image from this ImageComponent2D object.
|
void |
set(BufferedImage image)
Sets this image component to the specified BufferedImage
object.
|
void |
set(NioImageBuffer image)
Sets this image component to the specified NioImageBuffer
object.
|
void |
set(RenderedImage image)
Sets this image component to the specified RenderedImage
object.
|
void |
setSubImage(RenderedImage image,
int width,
int height,
int srcX,
int srcY,
int dstX,
int dstY)
Modifies a contiguous subregion of the image component.
|
void |
updateData(ImageComponent2D.Updater updater,
int x,
int y,
int width,
int height)
Updates image data that is accessed by reference.
|
getFormat, getHeight, getImageClass, getWidth, isByReference, isYUp, setYUp
cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
public ImageComponent2D(int format, int width, int height)
format
- the image component format, one of: FORMAT_RGB,
FORMAT_RGBA, etc.width
- the number of columns of pixels in this image component
objectheight
- the number of rows of pixels in this image component
objectIllegalArgumentException
- if format is invalid, or if
width or height are not positive.public ImageComponent2D(int format, BufferedImage image)
format
- the image component format, one of: FORMAT_RGB,
FORMAT_RGBA, etc.image
- the BufferedImage used to create this 2D image component.IllegalArgumentException
- if format is invalid, or if
the width or height of the image are not positive.public ImageComponent2D(int format, RenderedImage image)
format
- the image component format, one of: FORMAT_RGB,
FORMAT_RGBA, etc.image
- the RenderedImage used to create this 2D image componentIllegalArgumentException
- if format is invalid, or if
the width or height of the image are not positive.public ImageComponent2D(int format, int width, int height, boolean byReference, boolean yUp)
format
- the image component format, one of: FORMAT_RGB,
FORMAT_RGBA, etc.width
- the number of columns of pixels in this image component
objectheight
- the number of rows of pixels in this image component
objectbyReference
- a flag that indicates whether the data is copied
into this image component object or is accessed by reference.yUp
- a flag that indicates the y-orientation of this image
component. If yUp is set to true, the origin of the image is
the lower left; otherwise, the origin of the image is the upper
left.IllegalArgumentException
- if format is invalid, or if
width or height are not positive.public ImageComponent2D(int format, BufferedImage image, boolean byReference, boolean yUp)
format
- the image component format, one of: FORMAT_RGB,
FORMAT_RGBA, etc.image
- the BufferedImage used to create this 2D image componentbyReference
- a flag that indicates whether the data is copied
into this image component object or is accessed by referenceyUp
- a flag that indicates the y-orientation of this image
component. If yUp is set to true, the origin of the image is
the lower left; otherwise, the origin of the image is the upper
left.IllegalArgumentException
- if format is invalid, or if
the width or height of the image are not positive.public ImageComponent2D(int format, RenderedImage image, boolean byReference, boolean yUp)
format
- the image component format, one of: FORMAT_RGB,
FORMAT_RGBA, etc.image
- the RenderedImage used to create this 2D image componentbyReference
- a flag that indicates whether the data is copied
into this image component object or is accessed by reference.yUp
- a flag that indicates the y-orientation of this image
component. If yUp is set to true, the origin of the image is
the lower left; otherwise, the origin of the image is the upper
left.IllegalArgumentException
- if format is invalid, or if
the width or height of the image are not positive.public ImageComponent2D(int format, NioImageBuffer image, boolean byReference, boolean yUp)
format
- the image component format, one of: FORMAT_RGB,
FORMAT_RGBA, etc.image
- the NioImageBuffer used to create this 2D image componentbyReference
- a flag that indicates whether the data is copied
into this image component object or is accessed by reference.yUp
- a flag that indicates the y-orientation of this image
component. If yUp is set to true, the origin of the image is
the lower left; otherwise, the origin of the image is the upper
left.IllegalArgumentException
- if format is invalid, or if
the width or height of the image are not positive.IllegalArgumentException
- if the byReference flag is false.IllegalArgumentException
- if the yUp flag is false.IllegalArgumentException
- if the number of components in format
does not match the number of components in image.public void set(BufferedImage image)
The image class is set to ImageClass.BUFFERED_IMAGE.
image
- BufferedImage object containing the image.
Its size must be the same as the current size of this
ImageComponent2D object.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphIllegalArgumentException
- if the width and height of the
specified image is not equal to the width and height of this
ImageComponent object.public void set(RenderedImage image)
The image class is set to ImageClass.RENDERED_IMAGE if the the data access mode is by-reference and the specified RenderedImage is not an instance of BufferedImage. In all other cases, the image class is set to ImageClass.BUFFERED_IMAGE.
image
- RenderedImage object containing the image.
Its size must be the same as the current size of this
ImageComponent2D object.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphIllegalArgumentException
- if the width and height of the
specified image is not equal to the width and height of this
ImageComponent object.public void set(NioImageBuffer image)
The image class is set to ImageClass.NIO_IMAGE_BUFFER.
image
- NioImageBuffer object containing the image.
Its size must be the same as the current size of this
ImageComponent2D object.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphIllegalStateException
- if this ImageComponent object
is not yUp.IllegalArgumentException
- if the width and height of the
specified image is not equal to the width and height of this
ImageComponent object.IllegalArgumentException
- if the number of components in format
does not match the number of components in image.public BufferedImage getImage()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphIllegalStateException
- if the image class is not
ImageClass.BUFFERED_IMAGE.public RenderedImage getRenderedImage()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphIllegalStateException
- if the image class is not one of:
ImageClass.BUFFERED_IMAGE or ImageClass.RENDERED_IMAGE.public NioImageBuffer getNioImage()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphIllegalStateException
- if the image class is not
ImageClass.NIO_IMAGE_BUFFER.public void setSubImage(RenderedImage image, int width, int height, int srcX, int srcY, int dstX, int dstY)
image
- RenderedImage object containing the subimage.width
- width of the subregion.height
- height of the subregion.srcX
- starting X offset of the subregion in the
specified image.srcY
- starting Y offset of the subregion in the
specified image.dstX
- starting X offset of the subregion in the image
component of this object.dstY
- starting Y offset of the subregion in the image
component of this object.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphIllegalStateException
- if the data access mode is
BY_REFERENCE
.IllegalArgumentException
- if width
or
height
of
the subregion exceeds the dimension of the image of this object.IllegalArgumentException
- if dstX
< 0, or
(dstX
+ width
) > width of this object, or
dstY
< 0, or
(dstY
+ height
) > height of this object.IllegalArgumentException
- if srcX
< 0, or
(srcX
+ width
) > width of the RenderedImage
object containing the subimage, or
srcY
< 0, or
(srcY
+ height
) > height of the
RenderedImage object containing the subimage.IllegalArgumentException
- if the specified RenderedImage
is not compatible with the existing RenderedImage.IllegalStateException
- if the image class is not one of:
ImageClass.BUFFERED_IMAGE or ImageClass.RENDERED_IMAGE.public void updateData(ImageComponent2D.Updater updater, int x, int y, int width, int height)
The data to be modified has to be within the boundary of the subregion specified by the offset (x, y) and the dimension (width*height). It is illegal to modify data outside this boundary. If any referenced data is modified outisde the updateData method, or any data outside the specified boundary is modified, the results are undefined.
updater
- object whose updateData callback method will be
called to update the data referenced by this ImageComponent2D object.x
- starting X offset of the subregion.y
- starting Y offset of the subregion.width
- width of the subregion.height
- height of the subregion.CapabilityNotSetException
- if the appropriate capability
is not set, and this object is part of a live or compiled scene graphIllegalStateException
- if the data access mode is
BY_COPY
.IllegalArgumentException
- if width
or
height
of
the subregion exceeds the dimension of the image of this object.IllegalArgumentException
- if x
< 0, or
(x
+ width
) > width of this object, or
y
< 0, or
(y
+ height
) > height of this object.public NodeComponent cloneNodeComponent()
cloneNodeComponent
in class NodeComponent
Copyright © 2016–2022 SciJava. All rights reserved.