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 Summary
Fields Modifier and Type Field Description private QuickDrawContext
context
(package private) static boolean
DEBUG
private java.awt.Rectangle
frame
private java.util.List<java.awt.image.BufferedImage>
images
private long
imageStartStreamPos
private java.awt.Rectangle
lastRectangle
private java.awt.Point
penPosition
protected int
picSize
private double
screenImageXRatio
private double
screenImageYRatio
private int
version
-
Fields inherited from class com.twelvemonkeys.imageio.ImageReaderBase
imageInput
-
-
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 returnsnull
.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 adirectBitsRect
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 com.twelvemonkeys.imageio.ImageReaderBase
assertInput, checkBounds, dispose, fakeAOI, fakeSubsampling, getDestination, getNumImages, getStreamMetadata, hasExplicitDestination, reset, setInput
-
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
-
-
-
-
Field Detail
-
DEBUG
static final boolean DEBUG
-
context
private QuickDrawContext context
-
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
-
-
Method Detail
-
resetMembers
protected void resetMembers()
Description copied from class:ImageReaderBase
Resets all member variables. This method is by default invoked from:- Specified by:
resetMembers
in classImageReaderBase
-
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 adirectBitsRect
opcode.- Parameters:
pStream
- the stream to read frompPixmapCount
- 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 frompDestRect
- the rectangle to read into- Throws:
java.lang.NullPointerException
- ifpDestRect
isnull
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 frompBounds
- 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 frompBounds
- 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 classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getWidth
public int getWidth(int pIndex) throws java.io.IOException
- Specified by:
getWidth
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getHeight
public int getHeight(int pIndex) throws java.io.IOException
- Specified by:
getHeight
in classjavax.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 classjavax.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 returnsnull
.- Overrides:
getImageMetadata
in classImageReaderBase
- 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)
-
-