vrml.eai.field
Class EventInSFImage
java.lang.Object
vrml.eai.field.BaseField
vrml.eai.field.EventIn
vrml.eai.field.EventInSFImage
public abstract class EventInSFImage
- extends EventIn
Reference to a SFImage event-in slot. Use this class to write
values into SFImage event-in slots.
The following example demonstrates how to put a new texture
into a PixelTexture node. The texture has a size of 2 x 2 pixels and
RGB color values (3 components). The lower left pixel is white, the
lower right pixel red, the upper left pixel green, and the upper right
pixel blue:
vrml.eai.Node pixelTexture = ...;
vrml.eai.field.EventInSFImage set_image = (vrml.eai.field.EventInSFImage)pixelTexture.getEventIn("set_image");
int[] pixels = new int[] { 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF };
set_image.setValue(2, 2, 3, pixels);
Fields inherited from class vrml.eai.field.BaseField |
MFColor, MFFloat, MFInt32, MFNode, MFRotation, MFString, MFTime, MFVec2f, MFVec3f, SFBool, SFColor, SFFloat, SFImage, SFInt32, SFMatrix4f, SFNode, SFRotation, SFString, SFTime, SFVec2f, SFVec3f |
Method Summary |
abstract void |
setValue(int width,
int height,
int components,
int[] pixels)
Sets the value of the SFImage event-in slot. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EventInSFImage
protected EventInSFImage()
- Default constructor. This method is protected, i.e. you cannot create
new instances of this class. The only way to get instances is via the
Node.getEventIn(java.lang.String)
method.
setValue
public abstract void setValue(int width,
int height,
int components,
int[] pixels)
throws java.lang.IllegalArgumentException,
java.lang.ArrayIndexOutOfBoundsException
- Sets the value of the SFImage event-in slot.
The following example demonstrates how to put a new texture
into a PixelTexture node. The texture has a size of 2 x 2 pixels and
RGB color values (3 components). The lower left pixel is white, the
lower right pixel red, the upper left pixel green, and the upper right
pixel blue:
vrml.eai.Node pixelTexture = ...;
vrml.eai.field.EventInSFImage set_image = (vrml.eai.field.EventInSFImage)pixelTexture.getEventIn("set_image");
int[] pixels = new int[] { 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF };
set_image.setValue(2, 2, 3, pixels);
- Parameters:
width
- The width of the image, in pixels.height
- The height of the image, in pixels.components
- The number of color components per pixel. This value must be
between 1 and 4, inclusively. Greyscale images have 1 component
(intensity). Greyscale images with an alpha channel have 2 components
(intensity and alpha). Color images have 3 components (red, green and
blue). Color images with an alpha channel have 4 components (red,
green, blue and alpha).pixels
- The actual pixel values. These are at least width x height integer values.
The pixels are defined left to right, bottom to top, i.e. the first
pixel is in the lower left corner, and the last pixel is in the upper
right corner of the image. Each color component must be between 0
(no intensity resp. completely transparent) and 255 (full intensity
resp. completely opaque), inclusively. For one-component images, pixels
simply consist of a single intensity value, e.g. 0x00 in hexadecimal
(0 in decimal) for no intensity or 0xff in hexadecimal (256 in decimal)
for full intensity. For two-component images, pixels consist of an
intensity value in the upper byte, followed by an alpha value in the
lower byte, e.g. 0xff80 is semi-transparent full intensity. When you
have an intensity value and an alpha value, you can calculate the
resulting pixel like this: pixel = (intensity << 8) | alpha
.
For three-component images, pixels consist of the red component in the
highest byte, followed by green and finally blue in the lowest byte,
e.g. 0xFF0000 is red, 0x00FF00 is green, and 0x0000FF is blue. When
you have the red, green and blue value, you can calculate the resulting
pixel like this: pixel = (red << 16) | (green << 8) | blue
.
For four-component images, pixels consist of the red component in the
highest byte, followed by green, blue and finally alpha in the lowest
byte, e.g. 0xff000080 is semi-transparent red. When you have the red,
green, blue and alpha values, you can calculate the resulting pixel like this:
pixel = (red << 24) | (green << 16) | (blue << 8) | alpha
.
- Throws:
java.lang.IllegalArgumentException
- when any of the parameters contains
invalid values.
java.lang.ArrayIndexOutOfBoundsException
- when the pixels parameter contains
less than width x height components.