Class X3fImageData


  • public class X3fImageData
    extends Object
    Class for representing image data contained in X3F data.
    • Constructor Detail

      • X3fImageData

        protected X3fImageData​(RandomAccessData data,
                               int dataLength,
                               int rotation)
                        throws RandomAccessDataException,
                               HuffmanTree.PrefixException
        Constructor to parse and collect information contained in a X3F image section. It is assumed, that the current offset pointer of the data source is positioned just after the image data section identifier "SECi".
        Parameters:
        data - the data source containing the X3F data to parse
        dataLength - the length of the image data in bytes
        rotation - image rotation as given in X3F header
        Throws:
        RandomAccessDataException - if RandomAccessData source is invalid
        HuffmanTree.PrefixException - if the Huffman code word table is not prefix free
    • Method Detail

      • isImageFormatVersionSupported

        public boolean isImageFormatVersionSupported()
        Returns true, if the data version is supported by the parser.
        Returns:
        true, if the data version is supported
      • getImageFormatVersion

        public VersionNumber getImageFormatVersion()
        Returns the image format version.
        Returns:
        the image format version
      • getTypeImageData

        public UInt32 getTypeImageData()
        Returns the type of image data.
        Returns:
        the type of image data
      • getDataFormat

        public EnumX3fImageDataFormat getDataFormat()
        Returns the data format.
        data formats
        data formatdescription
        3Uncompressed 24-bit 8/8/8 RGB
        11Huffman-encoded DPCM 8/8/8 RGB
        18JPEG-compressed 8/8/8 RGB
        othersRESERVED
        Returns:
        the data format
      • getDataFormatNumericValue

        public UInt32 getDataFormatNumericValue()
        Returns the numeric value of the data format.
        Returns:
        the numeric value of the data format
      • getImageSize

        public ImageSize getImageSize()
        Returns the size of the image.
        Returns:
        the size of the image
      • getRowSize

        public UInt32 getRowSize()
        Returns row size in bytes. Will always be a multiple of 4 (32-bit aligned). A value of zero here means that rows are variable-length (as in Huffman data).
        Returns:
        row size in bytes
      • isProcessedForPreview

        public boolean isProcessedForPreview()
        Returns true, if the image is processed for preview.
        Returns:
        true, if the image is processed for preview
      • getDataOffset

        public long getDataOffset()
        Returns the offset in bytes of the image data from the start of the data.
        Returns:
        the offset in bytes of the image data
      • getDataLength

        public int getDataLength()
        Returns the length of the image data in bytes.
        Returns:
        the length of the image data
      • getHuffmanCodeWordTableDescription

        public String[] getHuffmanCodeWordTableDescription()
        Returns a bitwise string representation of the Huffman code word table entries.
        Returns:
        an array of strings, each containing a bitwise string representation of the Huffman code word table entry
      • getBufferedImage

        public BufferedImage getBufferedImage​(RandomAccessData data)
                                       throws RandomAccessDataException
        Returns a processed for preview image decoded as a BufferedImage. If the image is not processed for preview or the data format is not supported, null is returned.
        Parameters:
        data - the data source (it's current offset will be changed)
        Returns:
        processed for preview image decoded as a BufferedImage
        Throws:
        RandomAccessDataException - if RandomAccessData source is invalid
      • rotateImage

        public BufferedImage rotateImage​(BufferedImage src)
        Rotates the given image according to the rotation given in the X3F header.
        Parameters:
        src - given image to rotate
        Returns:
        rotated image