Class SoSFImage
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.fields.SoField
-
- com.openinventor.inventor.fields.SoSField
-
- com.openinventor.inventor.fields.SoSFImage
-
public class SoSFImage extends SoSField
Field containing a 2D image. A field containing a two-dimensional image. Images can be grayscale (intensity), grayscale with transparency information, RGB, or RGB with transparency. Each component of the image (intensity, red, green, blue or transparency (alpha)) can have an unsigned one-byte value from 0 to 255.Values are returned as arrays of unsigned chars. The image is stored in this array starting at the bottom left corner of the image with the intensity or red component of that pixel, followed by either the alpha, the green and blue, or the green, blue and alpha components (depending on the number of components in the image). The next value is the first component of the next pixel to the right.
SoSFImages are written to file as three integers representing the width, height and number of components in the image, followed by width*height hexadecimal values representing the pixels in the image, separated by whitespace. A one-component image will have one-byte hexadecimal values representing the intensity of the image. For example, 0xFF is full intensity, 0x00 is no intensity. A two-component image puts the intensity in the first (high) byte and the transparency in the second (low) byte. Pixels in a three-component image have the red component in the first (high) byte, followed by the green and blue components (so 0xFF0000 is red). Four-component images put the transparency byte after red/green/blue (so 0x0000FF80 is semi-transparent blue). Note: each pixel is actually read as a single unsigned number, so a 3-component pixel with value "0x0000FF" can also be written as "0xFF" or "255" (decimal).
For example,
is a 1 pixel wide by 2 pixel high grayscale image, with the bottom pixel white and the top pixel black. And:1 2 1 0xFF 0x00
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.2 4 3 0xFF0000 0xFF00 0 0 0 0 0xFFFFFF 0xFFFF00
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SoSFImage.CopyPolicies
SoSFImage
may be manipulating some large amounts of memory.static class
SoSFImage.DataTypes
Encoding data type.static class
SoSFImage.SubTextureImage
static class
SoSFImage.TextureImage
-
Nested classes/interfaces inherited from class com.openinventor.inventor.fields.SoField
SoField.FieldTypes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoSFImage(SoFieldContainer fieldContainer, java.lang.String fieldName, SoField.FieldTypes fieldType)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
int
getNumComponents()
Returns image's number of components.int
getNumSubTextures()
Returns true if subTextures have been defined or false if none have been defined.SoSFImage.SubTextureImage
getSubTexture(int index)
SoSFImage.TextureImage
getValue()
boolean
hasTransparency()
Returns true if the image contains any transparent pixels.boolean
isNeverWrite()
Queries the "neverWrite" flag.void
setNeverWrite(boolean neverWrite)
Sets the "neverWrite" flag.void
setValue(SbVec2i32 size, int nc, byte[] bytes)
void
setValue(SbVec2i32 size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject)
Calls setValue(size, nc, dataType, bufferObject, SoSFImage.CopyPolicies.valueOf( SoSFImage.CopyPolicies.COPY.getValue() )).void
setValue(SbVec2i32 size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject, SoSFImage.CopyPolicies copy)
void
setValue(SbVec2s size, int nc, byte[] bytes)
Same as above.void
setValue(SbVec2s size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject)
Calls setValue(size, nc, dataType, bufferObject, SoSFImage.CopyPolicies.valueOf( SoSFImage.CopyPolicies.COPY.getValue() )).void
setValue(SbVec2s size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject, SoSFImage.CopyPolicies copy)
SbRasterImage
toRasterImage()
Calls toRasterImage((boolean)true).SbRasterImage
toRasterImage(boolean downSample)
Returns an instance ofSbRasterImage
filled with the content of this field.-
Methods inherited from class com.openinventor.inventor.fields.SoField
appendConnection, appendConnection, connectFrom, connectFrom, disconnect, disconnect, disconnect, enableConnection, get, getConnectedEngine, getConnectedField, getContainer, getNumConnections, getValueSize, isConnected, isConnectedFromEngine, isConnectedFromField, isConnectedFromVRMLInterp, isConnectionEnabled, isDefault, isIgnored, set, setIgnored, touch
-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Constructor Detail
-
SoSFImage
public SoSFImage(SoFieldContainer fieldContainer, java.lang.String fieldName, SoField.FieldTypes fieldType)
Default constructor.
-
-
Method Detail
-
toRasterImage
public SbRasterImage toRasterImage()
Calls toRasterImage((boolean)true).
-
setValue
public void setValue(SbVec2i32 size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject)
Calls setValue(size, nc, dataType, bufferObject, SoSFImage.CopyPolicies.valueOf( SoSFImage.CopyPolicies.COPY.getValue() )).
-
setValue
public void setValue(SbVec2s size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject)
Calls setValue(size, nc, dataType, bufferObject, SoSFImage.CopyPolicies.valueOf( SoSFImage.CopyPolicies.COPY.getValue() )).
-
setNeverWrite
public void setNeverWrite(boolean neverWrite)
Sets the "neverWrite" flag. As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action. By default, the "neverWrite" condition is false.
-
getSubTexture
public SoSFImage.SubTextureImage getSubTexture(int index)
-
getNumSubTextures
public int getNumSubTextures()
Returns true if subTextures have been defined or false if none have been defined. Also returns the number of subTextures defined.
-
getValue
public SoSFImage.TextureImage getValue()
-
setValue
public void setValue(SbVec2i32 size, int nc, byte[] bytes)
-
setValue
public void setValue(SbVec2s size, int nc, byte[] bytes)
Same as above. Convenience method for the unsigned char datatype.
-
toRasterImage
public SbRasterImage toRasterImage(boolean downSample)
Returns an instance ofSbRasterImage
filled with the content of this field. It is useful to save the result of an SoRenderToTexture operation in feedback mode. The caller is responsible of the release of the returned raster image.When the content is not of type UNSIGNED_BYTE the data is downsampled to UNSIGNED_BYTE unless the downSample parameter is set to false.
Returns NULL if the content cannot be converted to an
SbRasterImage
.
-
hasTransparency
public boolean hasTransparency()
Returns true if the image contains any transparent pixels. Specifically if the image has 2 or 4 components and at least one pixel has an alpha value less then 255.
-
setValue
public void setValue(SbVec2s size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject, SoSFImage.CopyPolicies copy)
-
isNeverWrite
public boolean isNeverWrite()
Queries the "neverWrite" flag.
-
setValue
public void setValue(SbVec2i32 size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject, SoSFImage.CopyPolicies copy)
-
getNumComponents
public int getNumComponents()
Returns image's number of components.
-
-