Class EventInSFImage
- Direct Known Subclasses:
EventInSFImageWrapper
Images are represented as arrays of integers as per the VRML IS specification Section 5.5 SFImage. Pixel values are between 0 and 256 and represented as integers to maintain consistency with java's ImageConsumer interface and PixelGrabber class.
- Version:
- 1.0 30 April 1998
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
setValue
(int width, int height, int components, int[] pixels) Set the image value in the given eventIn.Methods inherited from class vrml.eai.field.EventIn
getUserData, setUserData
-
Constructor Details
-
EventInSFImage
protected EventInSFImage()Construct an instance of this class. Calls the superclass constructor with the field type set to SFImage.
-
-
Method Details
-
setValue
public abstract void setValue(int width, int height, int components, int[] pixels) Set the image value in the given eventIn.Image values are specified using a width, height and the number of components. The number of items in the pixels array must be at least
width * height
. If there are less items than this an ArrayIndexOutOfBoundsException will be generated. The integer values are represented according to the number of components. If the integer contains values in bytes that are not used by the number of components for that image, the values are ignored.1 Component Images
The integer has the intensity value stored in the lowest byte and can be obtained:intensity = pixel[i] &0xFF;
2 Component Images
The integer has the intensity value stored in the lowest byte and the transparency in the top byte:intensity = pixel[i] &0xFF; alpha = (pixel[i] >> 24) &0xFF00;
Note that this is different to the VRML representation of the image which would store the values in the text file asalpha = pixel[i] >> 8) &0xFF
. The reason for the difference is to maintain as much compatibility with the java image model as possible. Java does not contain a separate intensity only image model, instead it sets all three colour components to the same value. This way, the user of SFImages can take a full colour image and turn it to black + white by just setting the number of components to 2 - particularly if the three colour components are the same (which they are for an intensity only image) which will result in the correct intepretation of the image.3 Component Images
The three colour components are stored in the integer array as follows:red = (pixel[i] >> 16) &0xFF; green = (pixel[i] >> 8) &0xFF; blue = (pixel[i] ) &0xFF;
4 Component Images
The integer has the value stored in the array as follows:alpha = (pixel >> 24) &0xff; red = (pixel >> 16) &0xff; green = (pixel >> 8) &0xff; blue = (pixel ) &0xff;
The width and height values must be greater than or equal to zero. The number of components is between 1 and 4. Any value outside of these bounds will generate an IllegalArgumentException.
- Parameters:
width
- The width of the image in pixelsheight
- The height of the image in pixelscomponents
- The number of colour components [1-4]pixels
- The array of pixel values as specified above.- Throws:
IllegalArgumentException
- The number of components or width/ height are illegal values.ArrayIndexOutOfBoundsException
- The number of pixels provided by the caller is not enough for the width * height.
-