Class PICTImageReader


  • public final class PICTImageReader
    extends ImageReaderBase
    Reader for Apple Mac Paint Picture (PICT) format.
    Version:
    $Id: PICTReader.java,v 1.0 05.apr.2006 15:20:48 haku Exp$
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        PICTImageReader()
      Deprecated.
      protected PICTImageReader​(javax.imageio.spi.ImageReaderSpi pProvider)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void drawOnto​(java.awt.Graphics2D pGraphics)
      Reads the PICT stream.
      int getHeight​(int pIndex)  
      javax.imageio.metadata.IIOMetadata getImageMetadata​(int imageIndex)
      Default implementation that always returns null.
      java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int imageIndex)  
      private java.awt.Rectangle getPICTFrame()
      Open and read the frame size of the PICT file.
      int getWidth​(int pIndex)  
      private int getXPtCoord​(int pPoint)  
      private int getYPtCoord​(int pPoint)  
      static void main​(java.lang.String[] pArgs)  
      java.awt.image.BufferedImage read​(int pIndex, javax.imageio.ImageReadParam pParam)  
      private void readCompressedQT​(javax.imageio.stream.ImageInputStream pStream)  
      private byte[] readLongComment​(java.io.DataInput pStream)  
      private void readOpBits​(javax.imageio.stream.ImageInputStream pStream, boolean hasRegion)  
      private void readOpDirectBits​(javax.imageio.stream.ImageInputStream pStream, boolean hasRegion, int pPixmapCount)
      Reads the data following a directBitsRect opcode.
      private void readOpPackBits​(javax.imageio.stream.ImageInputStream pStream, boolean hasRegion, int pPixmapCount)  
      private void readPICTHeader​(javax.imageio.stream.ImageInputStream pStream)
      Read the PICT header.
      private void readPICTHeader0​(javax.imageio.stream.ImageInputStream pStream)  
      private void readPICTopcodes​(javax.imageio.stream.ImageInputStream pStream)
      Parse PICT opcodes in a PICT file.
      private java.awt.Polygon readPoly​(java.io.DataInput pStream, java.awt.Rectangle pBounds)
      Read in a polygon.
      private void readRectangle​(java.io.DataInput pStream, java.awt.Rectangle pDestRect)
      Reads the rectangle location and size from an 8-byte rectangle stream.
      private java.awt.geom.Area readRegion​(java.io.DataInput pStream, java.awt.Rectangle pBounds)
      Read in a region.
      protected void resetMembers()
      Resets all member variables.
      protected static void showIt​(java.awt.image.BufferedImage pImage, java.lang.String pTitle)  
      private void verbosePolyCmd​(java.lang.String pCmd, java.awt.Rectangle pBounds, java.awt.Polygon pPolygon)  
      private void verboseRegionCmd​(java.lang.String pCmd, java.awt.Rectangle pBounds, java.awt.geom.Area pRegion)  
      • Methods inherited from class javax.imageio.ImageReader

        abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, 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, readerSupportsThumbnails, readRaster, readThumbnail, 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
      • frame

        private java.awt.Rectangle frame
      • version

        private int version
      • penPosition

        private java.awt.Point penPosition
      • lastRectangle

        private java.awt.Rectangle lastRectangle
      • screenImageXRatio

        private double screenImageXRatio
      • screenImageYRatio

        private double screenImageYRatio
      • images

        private final java.util.List<java.awt.image.BufferedImage> images
      • imageStartStreamPos

        private long imageStartStreamPos
      • picSize

        protected int picSize
    • Constructor Detail

      • PICTImageReader

        @Deprecated
        public PICTImageReader()
        Deprecated.
      • PICTImageReader

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

      • getPICTFrame

        private java.awt.Rectangle getPICTFrame()
                                         throws java.io.IOException
        Open and read the frame size of the PICT file.
        Returns:
        return the PICT frame
        Throws:
        java.io.IOException - if an I/O error occurs while reading the image.
      • readPICTHeader

        private void readPICTHeader​(javax.imageio.stream.ImageInputStream pStream)
                             throws java.io.IOException
        Read the PICT header. The information read is shown on stdout if "DEBUG" is true.
        Parameters:
        pStream - the stream to read from
        Throws:
        java.io.IOException - if an I/O error occurs while reading the image.
      • readPICTHeader0

        private void readPICTHeader0​(javax.imageio.stream.ImageInputStream pStream)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • drawOnto

        private void drawOnto​(java.awt.Graphics2D pGraphics)
                       throws java.io.IOException
        Reads the PICT stream. The contents of the stream will be drawn onto the supplied graphics object.

        If "DEBUG" is true, the elements read are listed on stdout.

        Parameters:
        pGraphics - the graphics object to draw onto.
        Throws:
        javax.imageio.IIOException - if the data can not be read.
        java.io.IOException - if an I/O error occurs while reading the image.
      • readPICTopcodes

        private void readPICTopcodes​(javax.imageio.stream.ImageInputStream pStream)
                              throws java.io.IOException
        Parse PICT opcodes in a PICT file. The input stream must be positioned at the beginning of the opcodes, after picframe. If we have a non-null graphics, we try to draw the elements.
        Parameters:
        pStream - the stream to read from
        Throws:
        javax.imageio.IIOException - if the data can not be read.
        java.io.IOException - if an I/O error occurs while reading the image.
      • readCompressedQT

        private void readCompressedQT​(javax.imageio.stream.ImageInputStream pStream)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readOpPackBits

        private void readOpPackBits​(javax.imageio.stream.ImageInputStream pStream,
                                    boolean hasRegion,
                                    int pPixmapCount)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readOpDirectBits

        private void readOpDirectBits​(javax.imageio.stream.ImageInputStream pStream,
                                      boolean hasRegion,
                                      int pPixmapCount)
                               throws java.io.IOException
        Reads the data following a directBitsRect opcode.
        Parameters:
        pStream - the stream to read from
        pPixmapCount - the index of the bitmap in the PICT file, used for cahcing.
        Throws:
        javax.imageio.IIOException - if the data can not be read.
        java.io.IOException - if an I/O error occurs while reading the image.
      • readOpBits

        private void readOpBits​(javax.imageio.stream.ImageInputStream pStream,
                                boolean hasRegion)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readRectangle

        private void readRectangle​(java.io.DataInput pStream,
                                   java.awt.Rectangle pDestRect)
                            throws java.io.IOException
        Reads the rectangle location and size from an 8-byte rectangle stream.
        Parameters:
        pStream - the stream to read from
        pDestRect - the rectangle to read into
        Throws:
        java.lang.NullPointerException - if pDestRect is null
        java.io.IOException - if an I/O error occurs while reading the image.
      • readRegion

        private java.awt.geom.Area readRegion​(java.io.DataInput pStream,
                                              java.awt.Rectangle pBounds)
                                       throws java.io.IOException
        Read in a region. The input stream should be positioned at the first byte of the region. pBounds is a rectangle that will be set to the region bounds. The point array may therefore be empty if the region is just a rectangle.
        Parameters:
        pStream - the stream to read from
        pBounds - the bounds rectangle to read into
        Returns:
        the area containing the region, or an empty polygon if the region is a rectangle.
        Throws:
        java.io.IOException - if an I/O error occurs while reading the image.
      • readPoly

        private java.awt.Polygon readPoly​(java.io.DataInput pStream,
                                          java.awt.Rectangle pBounds)
                                   throws java.io.IOException
        Read in a polygon. The input stream should be positioned at the first byte of the polygon.
        Parameters:
        pStream - the stream to read from
        pBounds - the bounds rectangle to read into
        Returns:
        the polygon
        Throws:
        java.io.IOException - if an I/O error occurs while reading the image.
      • readLongComment

        private byte[] readLongComment​(java.io.DataInput pStream)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getXPtCoord

        private int getXPtCoord​(int pPoint)
      • getYPtCoord

        private int getYPtCoord​(int pPoint)
      • verbosePolyCmd

        private void verbosePolyCmd​(java.lang.String pCmd,
                                    java.awt.Rectangle pBounds,
                                    java.awt.Polygon pPolygon)
      • verboseRegionCmd

        private void verboseRegionCmd​(java.lang.String pCmd,
                                      java.awt.Rectangle pBounds,
                                      java.awt.geom.Area pRegion)
      • read

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

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

        public int getHeight​(int pIndex)
                      throws java.io.IOException
        Specified by:
        getHeight in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • 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
      • 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.
      • showIt

        protected static void showIt​(java.awt.image.BufferedImage pImage,
                                     java.lang.String pTitle)
      • main

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