Sets the value of the SFImage event-in slot.
Declaring type: EventInSFImage
Namespace: Vrml.EAI.Field
Assembly: VrmlEAI.NET
Collapse/Expand Syntax
C#
public abstract void SetValue (
        int width,
        int height,
        int components,
        int[] 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.
Collapse/Expand Example
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:
C#
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);