Class ImageComponent
- Direct Known Subclasses:
ImageComponent2D
,ImageComponent3D
Image data may be passed to this ImageComponent object in one of two ways: by copying the image data into this object or by accessing the image data by reference.
- By Copying: By default, the set and get image methods copy the image data into or out of this ImageComponent object. This is appropriate for many applications, since the application may reuse the RenderedImage object after copying it to the ImageComponent.
- By Reference:
A new feature in Java 3D version 1.2 allows image data to
be accessed by reference, directly from the RenderedImage object.
To use this feature, you need to construct an ImageComponent object
with the
byReference
flag set totrue
. In this mode, a reference to the input data is saved, but the data itself is not necessarily copied (although it may be, depending on the value of theyUp
flag, the format of the ImageComponent, and the format of the RenderedImage). Image data referenced by an ImageComponent object can only be modified via the updateData method. Applications must exercise care not to violate this rule. If any referenced RenderedImage is modified outside the updateData method after it has been passed to an ImageComponent object, the results are undefined. Another restriction in by-reference mode is that if the specified RenderedImage is not an instance of BufferedImage, then this ImageComponent cannot be used for readRaster or off-screen rendering operations, since these operations modify the ImageComponent data.
An image component object also specifies whether the orientation of
its image data is "y-up" or "y-down" (the default). Y-up mode
causes images to be interpreted as having their origin at the lower
left (rather than the default upper left) of a texture or raster
image with successive scan lines moving up. This is more
consistent with texture mapping data onto a surface, and maps
directly into the the way textures are used in OpenGL and other 3D
APIs. Setting the yUp
flag to true in conjunction
with setting the byReference
flag to true makes it
possible for Java 3D to avoid copying the texture map in some
cases.
Note that all color fields are treated as unsigned values, even though Java does not directly support unsigned variables. This means, for example, that an ImageComponent using a format of FORMAT_RGB5 can represent red, green, and blue values between 0 and 31, while an ImageComponent using a format of FORMAT_RGB8 can represent color values between 0 and 255. Even when byte values are used to create a RenderedImage with 8-bit color components, the resulting colors (bytes) are interpreted as if they were unsigned. Values greater than 127 can be assigned to a byte variable using a type cast. For example:
- byteVariable = (byte) intValue; // intValue can be > 127
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Used to specify the class of the image being wrapped. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Specifies that this ImageComponent object allows reading its format component information.static final int
Specifies that this ImageComponent object allows reading its image component information.static final int
Specifies that this ImageComponent object allows writing its image component information.static final int
Specifies that this ImageComponent object allows reading its size component information (width, height, and depth).static final int
Specifies that each pixel contains 1 8-bit channel: it can be used for only luminance or only alpha or only intensity.static final int
Specifies that each pixel contains 2 4-bit channels: one each for luminance and alpha.static final int
Specifies that each pixel contains 2 8-bit channels: one each for luminance and alpha.static final int
Specifies that each pixel contains 2 3-bit channels: one each for red, green, and 1 2-bit channel for blue.static final int
Specifies that each pixel contains 3 8-bit channels: one each for red, green, blue.static final int
Specifies that each pixel contains 3 4-bit channels: one each for red, green, blue.static final int
Specifies that each pixel contains 3 5-bit channels: one each for red, green, blue.static final int
Specifies that each pixel contains 3 5-bit channels: one each for red, green, blue and 1 1-bit channel for alpha.static final int
Specifies that each pixel contains 3 8-bit channels: one each for red, green, blue.static final int
Specifies that each pixel contains 4 8-bit channels: one each for red, green, blue, alpha.static final int
Specifies that each pixel contains 4 4-bit channels: one each for red, green, blue, alpha.static final int
Specifies that each pixel contains 4 8-bit channels: one each for red, green, blue, alpha. -
Constructor Summary
ConstructorsConstructorDescriptionImageComponent
(int format, int width, int height) Constructs an image component object using the specified format, width, and height.ImageComponent
(int format, int width, int height, boolean byReference, boolean yUp) Constructs an image component object using the specified format, width, height, byReference flag, and yUp flag. -
Method Summary
Modifier and TypeMethodDescriptionint
Retrieves the format of this image component object.int
Retrieves the height of this image component object.Retrieves the image class of this ImageComponent object.int
getWidth()
Retrieves the width of this image component object.boolean
Retrieves the data access mode for this ImageComponent object.boolean
isYUp()
Retrieves the y-orientation for this ImageComponent object.void
setYUp
(boolean yUp) Deprecated.as of Java 3D 1.5, the yUp flag should only be set at object construction time.Methods inherited from class javax.media.j3d.NodeComponent
cloneNodeComponent, cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
-
Field Details
-
FORMAT_RGB
Specifies that each pixel contains 3 8-bit channels: one each for red, green, blue. Same as FORMAT_RGB8.- See Also:
-
FORMAT_RGBA
Specifies that each pixel contains 4 8-bit channels: one each for red, green, blue, alpha. Same as FORMAT_RGBA8.- See Also:
-
FORMAT_RGB8
Specifies that each pixel contains 3 8-bit channels: one each for red, green, blue. Same as FORMAT_RGB.- See Also:
-
FORMAT_RGBA8
Specifies that each pixel contains 4 8-bit channels: one each for red, green, blue, alpha. Same as FORMAT_RGBA.- See Also:
-
FORMAT_RGB5
Specifies that each pixel contains 3 5-bit channels: one each for red, green, blue.- See Also:
-
FORMAT_RGB5_A1
Specifies that each pixel contains 3 5-bit channels: one each for red, green, blue and 1 1-bit channel for alpha.- See Also:
-
FORMAT_RGB4
Specifies that each pixel contains 3 4-bit channels: one each for red, green, blue.- See Also:
-
FORMAT_RGBA4
Specifies that each pixel contains 4 4-bit channels: one each for red, green, blue, alpha.- See Also:
-
FORMAT_LUM4_ALPHA4
Specifies that each pixel contains 2 4-bit channels: one each for luminance and alpha.- See Also:
-
FORMAT_LUM8_ALPHA8
Specifies that each pixel contains 2 8-bit channels: one each for luminance and alpha.- See Also:
-
FORMAT_R3_G3_B2
Specifies that each pixel contains 2 3-bit channels: one each for red, green, and 1 2-bit channel for blue.- See Also:
-
FORMAT_CHANNEL8
Specifies that each pixel contains 1 8-bit channel: it can be used for only luminance or only alpha or only intensity.- See Also:
-
ALLOW_SIZE_READ
public static final int ALLOW_SIZE_READSpecifies that this ImageComponent object allows reading its size component information (width, height, and depth).- See Also:
-
ALLOW_FORMAT_READ
public static final int ALLOW_FORMAT_READSpecifies that this ImageComponent object allows reading its format component information.- See Also:
-
ALLOW_IMAGE_READ
public static final int ALLOW_IMAGE_READSpecifies that this ImageComponent object allows reading its image component information.- See Also:
-
ALLOW_IMAGE_WRITE
public static final int ALLOW_IMAGE_WRITESpecifies that this ImageComponent object allows writing its image component information.- Since:
- Java 3D 1.3
- See Also:
-
-
Constructor Details
-
ImageComponent
public ImageComponent(int format, int width, int height) Constructs an image component object using the specified format, width, and height. Default values are used for all other parameters. The default values are as follows:-
byReference : false
yUp : false
- Parameters:
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 object- Throws:
IllegalArgumentException
- if format is invalid, or if width or height are not positive.
-
ImageComponent
public ImageComponent(int format, int width, int height, boolean byReference, boolean yUp) Constructs an image component object using the specified format, width, height, byReference flag, and yUp flag.- Parameters:
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.- Throws:
IllegalArgumentException
- if format is invalid, or if width or height are not positive.- Since:
- Java 3D 1.2
-
-
Method Details
-
getWidth
public int getWidth()Retrieves the width of this image component object.- Returns:
- the width of this image component object
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph
-
getHeight
public int getHeight()Retrieves the height of this image component object.- Returns:
- the height of this image component object
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph
-
getFormat
public int getFormat()Retrieves the format of this image component object.- Returns:
- the format of this image component object
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph
-
isByReference
public boolean isByReference()Retrieves the data access mode for this ImageComponent object.- Returns:
true
if the data access mode for this ImageComponent object is by-reference;false
if the data access mode is by-copying.- Since:
- Java 3D 1.2
-
setYUp
public void setYUp(boolean yUp) Deprecated.as of Java 3D 1.5, the yUp flag should only be set at object construction time.Sets the y-orientation of this ImageComponent object to y-up or y-down.- Parameters:
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.- Throws:
RestrictedAccessException
- if the method is called when this object is part of live or compiled scene graph.IllegalStateException
- if the image class of this object is ImageClass.NIO_IMAGE_BUFFER.- Since:
- Java 3D 1.2
-
isYUp
public boolean isYUp()Retrieves the y-orientation for this ImageComponent object.- Returns:
true
if the y-orientation of this ImageComponent object is y-up;false
if the y-orientation of this ImageComponent object is y-down.- Since:
- Java 3D 1.2
-
getImageClass
Retrieves the image class of this ImageComponent object.- Returns:
- the image class of this ImageComponent, one of: ImageClass.BUFFERED_IMAGE, ImageClass.RENDERED_IMAGE, or ImageClass.NIO_IMAGE_BUFFER.
- Since:
- Java 3D 1.5
-