5.5 SFImage
The SFImage field or event specifies a single uncompressed 2-dimensional
pixel image. SFImage fields and events are written to the VRML file as three
integers representing the width, height and number of components in the
image, followed by width*height hexadecimal or integer values representing
the pixels in the image, separated by whitespace:
fooImage <width> <height> <num components> <pixels values>
Pixel values are limited to 256 levels of intensity (i.e., 0-255 decimal
or 0x00-0xFF hexadecimal). A one-component image specifies one-byte hexadecimal
or integer values representing the intensity of the image. For example,
0xFF is full intensity in hexadecimal (255 in decimal), 0x00
is no intensity (0 in decimal). A two-component image specifies the intensity
in the first (high) byte and the alpha opacity in the second (low) byte.
Pixels in a three-component image specify the red component in the first
(high) byte, followed by the green and blue components (e.g., 0xFF0000
is red, 0x00FF00 is green, 0x0000FF is blue). Four-component
images specify the alpha opacity byte after red/green/blue (e.g., 0x0000FF80
is semi-transparent blue). A value of 0x00 is completely transparent,
0xFF is completely opaque. Note that alpha equals (1.0 - transparency),
if alpha and transparency range from 0.0 to 1.0.
Each pixel is read as a single unsigned number. For example, a 3-component
pixel with value 0x0000FF may also be written as 0xFF
(hexadecimal) or 255 (decimal). Pixels are specified from left
to right, bottom to top. The first hexadecimal value is the lower left pixel
and the last value is the upper right pixel.
For example,
fooImage 1 2 1 0xFF 0x00
is a 1 pixel wide by 2 pixel high one-component (i.e., greyscale)
image, with the bottom pixel white and the top pixel black. As another example,
fooImage 2 4 3 0xFF0000 0xFF00 0 0 0 0 0xFFFFFF 0xFFFF00
# red green black.. white yellow
is a 2 pixel wide by 4 pixel high RGB image, with the bottom left pixel
red, the bottom right pixel green, the two middle rows of pixels black,
the top left pixel white, and the top right pixel yellow.
The initial value of an SFImage eventOut is (0 0 0).