Class SoSFImage
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
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
SoSFImage
may be manipulating some large amounts of memory.static enum
Encoding data type.static class
static class
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
ConstructorsConstructorDescriptionSoSFImage
(SoFieldContainer fieldContainer, String fieldName, SoField.FieldTypes fieldType) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Returns image's number of components.int
Returns true if subTextures have been defined or false if none have been defined.getSubTexture
(int index) getValue()
boolean
Returns true if the image contains any transparent pixels.boolean
Queries the "neverWrite" flag.void
setNeverWrite
(boolean neverWrite) Sets the "neverWrite" flag.void
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
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) Calls toRasterImage((boolean)true).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 Details
-
SoSFImage
Default constructor.
-
-
Method Details
-
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() )). -
equals
-
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
-
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
-
setValue
-
setValue
Same as above. Convenience method for the unsigned char datatype. -
toRasterImage
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.
-