Class IFFImageReader


  • public final class IFFImageReader
    extends ImageReaderBase
    Reader for Commodore Amiga (Electronic Arts) IFF ILBM (InterLeaved BitMap) and PBM format (Packed BitMap). Also supports IFF RGB8 (Impulse) and IFF DEEP (TVPaint). The IFF format (Interchange File Format) is the standard file format supported by allmost all image software for the Amiga computer.

    This reader supports the original palette-based 1-8 bit formats, including EHB (Extra Half-Bright), HAM (Hold and Modify), and the more recent "deep" formats, 8 bit gray, 24 bit RGB and 32 bit ARGB. Uncompressed and ByteRun1 compressed (run length encoding) files are supported.

    Palette based images are read as BufferedImage of TYPE_BYTE_INDEXED or BufferedImage# depending on the bit depth. Gray images are read as TYPE_BYTE_GRAY. 24 bit true-color images are read as TYPE_3BYTE_BGR. 32 bit true-color images are read as TYPE_4BYTE_ABGR.

    Issues: HAM and HAM8 (Hold and Modify) formats are converted to RGB (24 bit), as it seems to be very hard to create an IndexColorModel subclass that would correctly describe these formats. These formats utilizes the special display hardware in the Amiga computers. HAM (6 bits) needs 12 bits storage/pixel, if unpacked to RGB (4 bits/gun). HAM8 (8 bits) needs 18 bits storage/pixel, if unpacked to RGB (6 bits/gun). See Wikipedia: HAM for more information.
    EHB palette is expanded to an IndexColorModel with 64 entries. See Wikipedia: EHB for more information.

    Version:
    $Id: IFFImageReader.java,v 1.0 29.aug.2004 20:26:58 haku Exp $
    See Also:
    Wikipedia: IFF, Wikipedia: IFF ILBM
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.DataInputStream byteRunStream  
      (package private) static boolean DEBUG  
      private Form header  
      • Fields inherited from class javax.imageio.ImageReader

        availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
    • Constructor Summary

      Constructors 
      Constructor Description
      IFFImageReader​(javax.imageio.spi.ImageReaderSpi pProvider)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getHeight​(int imageIndex)  
      javax.imageio.metadata.IIOMetadata getImageMetadata​(int imageIndex)
      Default implementation that always returns null.
      java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int imageIndex)  
      int getNumThumbnails​(int imageIndex)  
      javax.imageio.ImageTypeSpecifier getRawImageType​(int pIndex)  
      int getThumbnailHeight​(int imageIndex, int thumbnailIndex)  
      int getThumbnailWidth​(int imageIndex, int thumbnailIndex)  
      int getWidth​(int imageIndex)  
      private void hamToRGB​(byte[] indexed, java.awt.image.IndexColorModel colorModel, byte[] dest, int destOffset)  
      boolean hasThumbnails​(int imageIndex)  
      private void init​(int pIndex)  
      static void main​(java.lang.String[] args)  
      private void multiPaletteToRGB​(int row, byte[] indexed, java.awt.image.IndexColorModel colorModel, byte[] dest, int destOffset)  
      private boolean needsConversionToRGB()  
      java.awt.image.BufferedImage read​(int imageIndex, javax.imageio.ImageReadParam param)  
      private void readBody​(javax.imageio.ImageReadParam param, java.awt.image.BufferedImage destination)  
      private void readChunky​(javax.imageio.ImageReadParam param, java.awt.image.BufferedImage destination, javax.imageio.stream.ImageInputStream input)  
      boolean readerSupportsThumbnails()  
      private void readInterleaved​(javax.imageio.ImageReadParam param, java.awt.image.BufferedImage destination, javax.imageio.stream.ImageInputStream input)  
      private void readInterleavedIndexed​(javax.imageio.ImageReadParam param, java.awt.image.BufferedImage destination, java.awt.image.IndexColorModel palette, javax.imageio.stream.ImageInputStream input)  
      private void readMeta()  
      private void readPlaneData​(byte[] destination, int offset, int planeWidth, javax.imageio.stream.ImageInputStream input)  
      java.awt.image.BufferedImage readThumbnail​(int imageIndex, int thumbnailIndex)  
      protected void resetMembers()
      Resets all member variables.
      • Methods inherited from class javax.imageio.ImageReader

        abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getOriginatingProvider, getSourceRegion, getStreamMetadata, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readRaster, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEBUG

        static final boolean DEBUG
      • header

        private Form header
      • byteRunStream

        private java.io.DataInputStream byteRunStream
    • Constructor Detail

      • IFFImageReader

        IFFImageReader​(javax.imageio.spi.ImageReaderSpi pProvider)
    • Method Detail

      • init

        private void init​(int pIndex)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readMeta

        private void readMeta()
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public java.awt.image.BufferedImage read​(int imageIndex,
                                                 javax.imageio.ImageReadParam param)
                                          throws java.io.IOException
        Specified by:
        read in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • readerSupportsThumbnails

        public boolean readerSupportsThumbnails()
        Overrides:
        readerSupportsThumbnails in class javax.imageio.ImageReader
      • hasThumbnails

        public boolean hasThumbnails​(int imageIndex)
                              throws java.io.IOException
        Overrides:
        hasThumbnails in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getNumThumbnails

        public int getNumThumbnails​(int imageIndex)
                             throws java.io.IOException
        Overrides:
        getNumThumbnails in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getThumbnailWidth

        public int getThumbnailWidth​(int imageIndex,
                                     int thumbnailIndex)
                              throws java.io.IOException
        Overrides:
        getThumbnailWidth in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getThumbnailHeight

        public int getThumbnailHeight​(int imageIndex,
                                      int thumbnailIndex)
                               throws java.io.IOException
        Overrides:
        getThumbnailHeight in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • readThumbnail

        public java.awt.image.BufferedImage readThumbnail​(int imageIndex,
                                                          int thumbnailIndex)
                                                   throws java.io.IOException
        Overrides:
        readThumbnail in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getWidth

        public int getWidth​(int imageIndex)
                     throws java.io.IOException
        Specified by:
        getWidth in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getHeight

        public int getHeight​(int imageIndex)
                      throws java.io.IOException
        Specified by:
        getHeight in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getImageMetadata

        public javax.imageio.metadata.IIOMetadata getImageMetadata​(int imageIndex)
                                                            throws java.io.IOException
        Description copied from class: ImageReaderBase
        Default implementation that always returns null.
        Overrides:
        getImageMetadata in class ImageReaderBase
        Parameters:
        imageIndex - ignored, unless overridden
        Returns:
        null, unless overridden
        Throws:
        java.io.IOException - never, unless overridden.
      • getImageTypes

        public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int imageIndex)
                                                                           throws java.io.IOException
        Specified by:
        getImageTypes in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getRawImageType

        public javax.imageio.ImageTypeSpecifier getRawImageType​(int pIndex)
                                                         throws java.io.IOException
        Overrides:
        getRawImageType in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • needsConversionToRGB

        private boolean needsConversionToRGB()
      • readBody

        private void readBody​(javax.imageio.ImageReadParam param,
                              java.awt.image.BufferedImage destination)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • readInterleavedIndexed

        private void readInterleavedIndexed​(javax.imageio.ImageReadParam param,
                                            java.awt.image.BufferedImage destination,
                                            java.awt.image.IndexColorModel palette,
                                            javax.imageio.stream.ImageInputStream input)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readChunky

        private void readChunky​(javax.imageio.ImageReadParam param,
                                java.awt.image.BufferedImage destination,
                                javax.imageio.stream.ImageInputStream input)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readInterleaved

        private void readInterleaved​(javax.imageio.ImageReadParam param,
                                     java.awt.image.BufferedImage destination,
                                     javax.imageio.stream.ImageInputStream input)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readPlaneData

        private void readPlaneData​(byte[] destination,
                                   int offset,
                                   int planeWidth,
                                   javax.imageio.stream.ImageInputStream input)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • multiPaletteToRGB

        private void multiPaletteToRGB​(int row,
                                       byte[] indexed,
                                       java.awt.image.IndexColorModel colorModel,
                                       byte[] dest,
                                       int destOffset)
      • hamToRGB

        private void hamToRGB​(byte[] indexed,
                              java.awt.image.IndexColorModel colorModel,
                              byte[] dest,
                              int destOffset)
      • main

        public static void main​(java.lang.String[] args)