Class PICTImageReader

java.lang.Object
javax.imageio.ImageReader
com.twelvemonkeys.imageio.ImageReaderBase
com.twelvemonkeys.imageio.plugins.pict.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$
  • Field Details

    • DEBUG

      static final boolean DEBUG
    • context

      private QuickDrawContext context
    • frame

      private Rectangle frame
    • version

      private int version
    • penPosition

      private Point penPosition
    • lastRectangle

      private Rectangle lastRectangle
    • screenImageXRatio

      private double screenImageXRatio
    • screenImageYRatio

      private double screenImageYRatio
    • images

      private final List<BufferedImage> images
    • imageStartStreamPos

      private long imageStartStreamPos
    • picSize

      protected int picSize
  • Constructor Details

    • PICTImageReader

      @Deprecated public PICTImageReader()
      Deprecated.
    • PICTImageReader

      protected PICTImageReader(ImageReaderSpi pProvider)
  • Method Details

    • resetMembers

      protected void resetMembers()
      Description copied from class: ImageReaderBase
      Resets all member variables. This method is by default invoked from:
      Specified by:
      resetMembers in class ImageReaderBase
    • getPICTFrame

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

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

      private void readPICTHeader0(ImageInputStream pStream) throws IOException
      Throws:
      IOException
    • drawOnto

      private void drawOnto(Graphics2D pGraphics) throws 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:
      IIOException - if the data can not be read.
      IOException - if an I/O error occurs while reading the image.
    • readPICTopcodes

      private void readPICTopcodes(ImageInputStream pStream) throws 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:
      IIOException - if the data can not be read.
      IOException - if an I/O error occurs while reading the image.
    • readCompressedQT

      private void readCompressedQT(ImageInputStream pStream) throws IOException
      Throws:
      IOException
    • readOpPackBits

      private void readOpPackBits(ImageInputStream pStream, boolean hasRegion, int pPixmapCount) throws IOException
      Throws:
      IOException
    • readOpDirectBits

      private void readOpDirectBits(ImageInputStream pStream, boolean hasRegion, int pPixmapCount) throws 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:
      IIOException - if the data can not be read.
      IOException - if an I/O error occurs while reading the image.
    • readOpBits

      private void readOpBits(ImageInputStream pStream, boolean hasRegion) throws IOException
      Throws:
      IOException
    • readRectangle

      private void readRectangle(DataInput pStream, Rectangle pDestRect) throws 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:
      NullPointerException - if pDestRect is null
      IOException - if an I/O error occurs while reading the image.
    • readRegion

      private Area readRegion(DataInput pStream, Rectangle pBounds) throws 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:
      IOException - if an I/O error occurs while reading the image.
    • readPoly

      private Polygon readPoly(DataInput pStream, Rectangle pBounds) throws 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:
      IOException - if an I/O error occurs while reading the image.
    • readLongComment

      private byte[] readLongComment(DataInput pStream) throws IOException
      Throws:
      IOException
    • getXPtCoord

      private int getXPtCoord(int pPoint)
    • getYPtCoord

      private int getYPtCoord(int pPoint)
    • verbosePolyCmd

      private void verbosePolyCmd(String pCmd, Rectangle pBounds, Polygon pPolygon)
    • verboseRegionCmd

      private void verboseRegionCmd(String pCmd, Rectangle pBounds, Area pRegion)
    • read

      public BufferedImage read(int pIndex, ImageReadParam pParam) throws IOException
      Specified by:
      read in class ImageReader
      Throws:
      IOException
    • getWidth

      public int getWidth(int pIndex) throws IOException
      Specified by:
      getWidth in class ImageReader
      Throws:
      IOException
    • getHeight

      public int getHeight(int pIndex) throws IOException
      Specified by:
      getHeight in class ImageReader
      Throws:
      IOException
    • getImageTypes

      public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException
      Specified by:
      getImageTypes in class ImageReader
      Throws:
      IOException
    • getImageMetadata

      public IIOMetadata getImageMetadata(int imageIndex) throws 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:
      IOException - never, unless overridden.
    • showIt

      protected static void showIt(BufferedImage pImage, String pTitle)
    • main

      public static void main(String[] pArgs)