Class SoSFImage3


  • public class SoSFImage3
    extends SoSField
    Field containing a 3D image. A field containing a three-dimensional image. A three-dimensional image can be thought of as a sequence of two-dimensional image "slices."

    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 front 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.

    SoSFImage3s are written to file as four integers representing the width, height, depth and number of components in the image, followed by width*height*depth 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,

       1 2 3 1 0xFF 0x00 0x00 0xFF 0xFF 0x00
    is a 1 pixel wide by 2 pixel high by 3 pixel deep grayscale image, with the bottom pixel white and the top pixel black in the first (front-most) slice. In the second slice the bottom pixel is black and the top pixel is white. And:

       2 4 3 3 0xFF0000 0xFF00 0 0 0 0 0xFFFFFF 0xFFFF00 ...
    is a 2 pixel wide by 4 pixel high by 3 pixel deep 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 in the first slice. Subsequent slices are not shown.

    See Also:
    SoField, SoSField
    • Method Detail

      • setValue

        public void setValue​(SbVec3s size,
                             int nc,
                             SoBufferObject bufferObject)
        Calls setValue(size, nc, bufferObject, SoSFImage3.CopyPolicies.valueOf( SoSFImage3.CopyPolicies.COPY.getValue() )).
      • setValue

        public void setValue​(SbVec3i32 size,
                             int nc,
                             SoSFImage.DataTypes dataType,
                             SoBufferObject bufferObject)
        Calls setValue(size, nc, dataType, bufferObject, SoSFImage3.CopyPolicies.valueOf( SoSFImage3.CopyPolicies.COPY.getValue() )).
      • setValue

        public void setValue​(SbVec3s size,
                             int nc,
                             SoBufferObject bufferObject,
                             SoSFImage3.CopyPolicies copy)
        Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values. size[0]*size[1]*size[2]*nc*sizeof( <dataType>) bytes from the given array will be copied into internal storage maintained by the SoSFImage3 field.

        At times, SoSFImage3 may need to manipulate large amounts of memory. Therefore, it is useful to be able to specify the memory usage policy dynamically. By default, the memory policy is COPY, which is consistent with other Open Inventor fields. The most likely to be efficient is NO_COPY. See also setNeverWrite().

      • setValue

        public void setValue​(SbVec3i32 size,
                             int nc,
                             SoSFImage.DataTypes dataType,
                             SoBufferObject bufferObject,
                             SoSFImage3.CopyPolicies copy)
        Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values. size[0]*size[1]*size[2]*nc*sizeof( <dataType>) bytes from the given array will be copied into internal storage maintained by the SoSFImage3 field.

        At times, SoSFImage3 may need to manipulate large amounts of memory. Therefore, it is useful to be able to specify the memory usage policy dynamically. By default, the memory policy is COPY, which is consistent with other Open Inventor fields. The most likely to be efficient is NO_COPY. See also setNeverWrite().

      • getSubTexture

        public SoSFImage3.SubTextureImage getSubTexture​(int index)
        Returns a buffer to a given subTexture set by setSubValue, setSubValues, or a startEditing()/finishEditing() pair. These methods append subTextures to a list. Also returns the size of the subtexture and the offset from the beginning of the image of the requested subImage.
        This is a convenience method for the unsigned char datatype.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class SoField
      • 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 SoSFImage3.TextureImage getValue()
        Returns the pixels in the image as an array of unsigned chars. The size and nc arguments are filled in with the dimensions of the image and the number of components in the image; the number of bytes in the array returned will be size [0]* size [1]* size [2]* nc *sizeof( <dataType>).
        This is a convenience method for the unsigned char datatype.
      • getNumComponents

        public int getNumComponents()
        Returns the number of components in each pixels of the image.
      • isNeverWrite

        public boolean isNeverWrite()
        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 true.
      • getBufferObject

        public SoSFImage3.BufferObject getBufferObject()
        Returns the pixels in the image as a buffer object. The size and nc arguments are filled in with the dimensions of the image and the number of components in the image; the number of bytes in the array returned will be size [0]* size [1]* size [2]* nc .
      • setNeverWrite

        public void setNeverWrite​(boolean neverWrite)
        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 true.