Class GraphicsImage

  • All Implemented Interfaces:
    java.io.Serializable, StreamInterface

    public class GraphicsImage
    extends GraphicsObject
    implements StreamInterface, java.io.Serializable
    The color image data is stored so that the red channel is in low memory, the green channel is next, the blue channel after that, and the alpha channel in high memory. For example, the first pixel has the following layout. IT_RGB888: r = aucData[0]; g = aucData[1]; b = aucData[2]; IT_RGBA8888: r = aucData[0]; g = aucData[1]; b = aucData[2]; a = aucData[3]; Depth image data is always 'float' with values in [0,1]. The specification of 16, 24, or 32 is for setting up the hardware with the correct size depth buffer. Data read into a depth image from the depth buffer will be converted to [0,1] if necessary. Construction and destruction. GraphicsImage accepts responsibility for deleting the input array. The acImageName field is used as a unique identifier for the image for purposes of sharing. The caller of the constructor may provided a name. If not, the constructor generates a unique name "imageN.wmif" where N is the Object::m_uiID field. A global map of images is maintained for sharing purposes. NOTE: GraphicsImage dimensions must be a power of two. Assert statements are placed in the constructors to trap when the dimensions are not power of two.
    See Also:
    Serialized Form
    • Field Detail

      • ms_pkFormatModeMap

        private static java.util.HashMap<java.lang.Integer,​GraphicsImage.FormatMode> ms_pkFormatModeMap
        For a lookup of the renderer constant type from its string name.
      • ms_pkTypeMap

        private static java.util.HashMap<java.lang.Integer,​GraphicsImage.Type> ms_pkTypeMap
        For a lookup of the renderer constant type from its string name.
      • m_eTypeStatic

        private static GraphicsImage.Type m_eTypeStatic
        Initializes format mode static enum:
      • fInv255

        private static final float fInv255
        Converting from 0-255 range to 0-1 range.
        See Also:
        Constant Field Values
      • m_iDimension

        protected int m_iDimension
        Image number of dimensions.
      • m_aiBound

        protected int[] m_aiBound
        Image extents.
      • m_iQuantity

        protected int m_iQuantity
        Image size.
      • m_aucData

        protected byte[] m_aucData
        Image byte data.
      • m_afData

        protected float[] m_afData
        Image float data.
      • m_kBuffer

        protected java.nio.Buffer m_kBuffer
      • m_bUpdateBuffer

        protected boolean m_bUpdateBuffer
    • Constructor Detail

      • GraphicsImage

        public GraphicsImage()
        Default constructor.
      • GraphicsImage

        public GraphicsImage​(GraphicsImage.FormatMode eFormat,
                             int iBound0,
                             byte[] aucData,
                             java.lang.String acImageName)
        Construct a 1D image (byte)
        Parameters:
        eFormat - image format
        iBound0 - size of image.
        aucData - image data.
        acImageName - image name.
      • GraphicsImage

        public GraphicsImage​(GraphicsImage.FormatMode eFormat,
                             int iBound0,
                             float[] afData,
                             java.lang.String acImageName)
        Construct a 1D image (float)
        Parameters:
        eFormat - image format
        iBound0 - size of image.
        afData - image data.
        acImageName - image name.
      • GraphicsImage

        public GraphicsImage​(GraphicsImage.FormatMode eFormat,
                             int iBound0,
                             int iBound1,
                             byte[] aucData,
                             java.lang.String acImageName)
        Construct a 2D image (byte)
        Parameters:
        eFormat - image format
        iBound0 - image dimension 1.
        iBound1 - image dimension 2.
        aucData - image data.
        acImageName - image name.
      • GraphicsImage

        public GraphicsImage​(GraphicsImage.FormatMode eFormat,
                             int iBound0,
                             int iBound1,
                             float[] afData,
                             java.lang.String acImageName)
        Construct a 2D image (float)
        Parameters:
        eFormat - image format
        iBound0 - image dimension 1.
        iBound1 - image dimension 2.
        afData - image data.
        acImageName - image name.
      • GraphicsImage

        public GraphicsImage​(GraphicsImage.FormatMode eFormat,
                             int iBound0,
                             int iBound1,
                             int iBound2,
                             byte[] aucData,
                             java.lang.String acImageName)
        Construct a 3D image (byte)
        Parameters:
        eFormat - image format
        iBound0 - image dimension 1.
        iBound1 - image dimension 2.
        iBound2 - image dimension 3.
        aucData - image data.
        acImageName - image name.
      • GraphicsImage

        public GraphicsImage​(GraphicsImage.FormatMode eFormat,
                             int iBound0,
                             int iBound1,
                             int iBound2,
                             float[] afData,
                             java.lang.String acImageName)
        Construct a 3D image (float)
        Parameters:
        eFormat - image format
        iBound0 - image dimension 1.
        iBound1 - image dimension 2.
        iBound2 - image dimension 3.
        afData - image data.
        acImageName - image name.
    • Method Detail

      • GetBytesPerPixel

        public static final int GetBytesPerPixel​(GraphicsImage.FormatMode eFormat)
        Get the number of bytes per pixel for the given format enum.
        Parameters:
        eFormat - format type.
        Returns:
        the number of bytes per pixel for the given format enum.
      • GetFormatName

        public static java.lang.String GetFormatName​(GraphicsImage.FormatMode eFormat)
        Return image format name for the input enum.
        Parameters:
        eFormat - format enum.
        Returns:
        image format name.
      • Load

        public static GraphicsImage Load​(java.lang.String acImageName,
                                         java.lang.String rkDirectory)
        Streaming support. The sharing system is automatically invoked by these calls. In Load, if an image corresponding to the filename is already in memory, then that image is returned (i.e. shared). Otherwise, a new image is created and returned. The filename is used as the image name.
        Parameters:
        acImageName - image name
        rkDirectory - directory where the image is located.
        Returns:
        new GraphicsImage or null if it cannot be loaded.
      • LoadFile

        private static java.io.ByteArrayInputStream LoadFile​(java.lang.String acFilename)
        Opens an input stream from the input filename.
        Parameters:
        acFilename - image file name.
        Returns:
        an input stream for reading the file.
      • LoadImage

        public static GraphicsImage LoadImage​(java.lang.String acImageName,
                                              java.lang.String rkDirectory,
                                              java.lang.String kExtension)
      • CopyRGBA

        public void CopyRGBA​(ColorRGBA[] akCImage)
        Copy to an already existing image of ColorRGBA values.
        Parameters:
        akCImage - The input array must have the correct dimensions as the GraphicsImage itself.
      • CreateRGBA

        public ColorRGBA[] CreateRGBA()
        Create an image of ColorRGBA values.
        Returns:
        an image of the same width and height for these formats. The returned image is dynamically allocated; the caller is responsible for deleting it.
      • GetBound

        public int GetBound​(int i)
        Get the image extent in the given dimension.
        Parameters:
        i - dimension.
        Returns:
        the image extent in the given dimension.
      • GetBytesPerPixel

        public final int GetBytesPerPixel()
        Get the number of bytes per pixel in the image.
        Returns:
        the number of bytes per pixel in the image.
      • GetData

        public final byte[] GetData()
        Get the image data.
        Returns:
        the image data.
      • GetDataBuffer

        public java.nio.Buffer GetDataBuffer()
        Get the imag data in Buffer format.
        Returns:
        the imag data in Buffer format.
      • GetDimension

        public final int GetDimension()
        Get the dimension of this image (1D, 2D, 3D).
        Returns:
        the dimension of this image (1D, 2D, 3D).
      • GetDiskUsed

        public int GetDiskUsed​(StreamVersion rkVersion)
        Returns the size of this object and it's children on disk for the current StreamVersion parameter.
        Specified by:
        GetDiskUsed in interface StreamInterface
        Overrides:
        GetDiskUsed in class GraphicsObject
        Parameters:
        rkVersion - the current version of the Stream file being created.
        Returns:
        the size of this object on disk.
      • GetFloatData

        public float[] GetFloatData()
        Get image float data.
        Returns:
        image float data.
      • GetFormatName

        public final java.lang.String GetFormatName()
        Return image format name.
        Returns:
        image format name.
      • GetQuantity

        public final int GetQuantity()
        Get the image size.
        Returns:
        the image size.
      • GetType

        public final GraphicsImage.Type GetType()
        Get the image size.
        Returns:
        the image size.
      • InitDataBuffer

        public void InitDataBuffer()
        Allocate the data array based on the image type.
      • IsCubeImage

        public final boolean IsCubeImage()
        Return true if this is a cube image.
        Returns:
        true if this is a cube image.
      • IsDepthImage

        public final boolean IsDepthImage()
        Return true if this is a depth image.
        Returns:
        true if this is a depth image.
      • Load

        public void Load​(Stream rkStream,
                         Stream.Link pkLink)
        Loads this object from the input parameter rkStream, using the input Stream.Link to store the IDs of children objects of this object for linking after all objects are loaded from the Stream.
        Specified by:
        Load in interface StreamInterface
        Overrides:
        Load in class GraphicsObject
        Parameters:
        rkStream - the Stream from which this object is being read.
        pkLink - the Link class for storing the IDs of this object's children objects.
      • Save

        public void Save​(Stream rkStream)
        Write this object and all it's children to the Stream.
        Specified by:
        Save in interface StreamInterface
        Overrides:
        Save in class GraphicsObject
        Parameters:
        rkStream - the Stream where the child objects are stored.
      • SaveStrings

        public StringTree SaveStrings​(java.lang.String acTitle)
        Write this object into a StringTree for the scene-graph visualization.
        Specified by:
        SaveStrings in interface StreamInterface
        Overrides:
        SaveStrings in class GraphicsObject
        Parameters:
        acTitle - the header for this object in the StringTree.
        Returns:
        StringTree containing a String-based representation of this object and it's children.
      • SetData

        public void SetData​(java.nio.Buffer kBuffer,
                            int iZ)
      • SetData

        public void SetData​(byte[] aucData,
                            int iSize)
        Set the image data for 1D image.
        Parameters:
        aucData - new image data.
        iSize - new image size.
      • SetData

        public void SetData​(byte[] aucData,
                            int iXSize,
                            int iYSize)
        Set the image data for 2D image.
        Parameters:
        aucData - new image data.
        iXSize - new image x-size.
        iYSize - new image y-size.
      • SetData

        public void SetData​(byte[] aucData,
                            int iXSize,
                            int iYSize,
                            int iZSize)
        Set the image data for 3D image.
        Parameters:
        aucData - new image data.
        iXSize - new image x-size.
        iYSize - new image y-size.
        iZSize - new image z-size.
      • SetData

        public void SetData​(java.nio.ByteBuffer kBuffer,
                            int iZ)
      • SetData

        public void SetData​(float[] afData,
                            int iXSize,
                            int iYSize)
        Set the image data for 2D image.
        Parameters:
        afData - new image data.
        iXSize - new image x-size.
        iYSize - new image y-size.
      • SetFloatData

        public void SetFloatData​(float[] afData,
                                 int iSize)
        Set the image data for 1D image.
        Parameters:
        afData - new image data.
        iSize - new image size.
      • SetFloatData

        public void SetFloatData​(float[] afData,
                                 int iXSize,
                                 int iYSize)
        Set the image data for 2D image.
        Parameters:
        afData - new image data.
        iXSize - new image x-size.
        iYSize - new image y-size.
      • SetFloatData

        public void SetFloatData​(float[] afData,
                                 int iXSize,
                                 int iYSize,
                                 int iZSize)
        Set the image data for 3D image.
        Parameters:
        afData - new image data.
        iXSize - new image x-size.
        iYSize - new image y-size.
        iZSize - new image z-size.