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 QuickDrawContextcontext(package private) static booleanDEBUGprivate java.awt.Rectangleframeprivate java.util.List<java.awt.image.BufferedImage>imagesprivate longimageStartStreamPosprivate java.awt.RectanglelastRectangleprivate java.awt.PointpenPositionprotected intpicSizeprivate doublescreenImageXRatioprivate doublescreenImageYRatioprivate intversion-
Fields inherited from class com.twelvemonkeys.imageio.ImageReaderBase
imageInput
-
-
Constructor Summary
Constructors Modifier Constructor Description PICTImageReader()Deprecated.protectedPICTImageReader(javax.imageio.spi.ImageReaderSpi pProvider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voiddrawOnto(java.awt.Graphics2D pGraphics)Reads the PICT stream.intgetHeight(int pIndex)javax.imageio.metadata.IIOMetadatagetImageMetadata(int imageIndex)Default implementation that always returnsnull.java.util.Iterator<javax.imageio.ImageTypeSpecifier>getImageTypes(int imageIndex)private java.awt.RectanglegetPICTFrame()Open and read the frame size of the PICT file.intgetWidth(int pIndex)private intgetXPtCoord(int pPoint)private intgetYPtCoord(int pPoint)static voidmain(java.lang.String[] pArgs)java.awt.image.BufferedImageread(int pIndex, javax.imageio.ImageReadParam pParam)private voidreadCompressedQT(javax.imageio.stream.ImageInputStream pStream)private byte[]readLongComment(java.io.DataInput pStream)private voidreadOpBits(javax.imageio.stream.ImageInputStream pStream, boolean hasRegion)private voidreadOpDirectBits(javax.imageio.stream.ImageInputStream pStream, boolean hasRegion, int pPixmapCount)Reads the data following adirectBitsRectopcode.private voidreadOpPackBits(javax.imageio.stream.ImageInputStream pStream, boolean hasRegion, int pPixmapCount)private voidreadPICTHeader(javax.imageio.stream.ImageInputStream pStream)Read the PICT header.private voidreadPICTHeader0(javax.imageio.stream.ImageInputStream pStream)private voidreadPICTopcodes(javax.imageio.stream.ImageInputStream pStream)Parse PICT opcodes in a PICT file.private java.awt.PolygonreadPoly(java.io.DataInput pStream, java.awt.Rectangle pBounds)Read in a polygon.private voidreadRectangle(java.io.DataInput pStream, java.awt.Rectangle pDestRect)Reads the rectangle location and size from an 8-byte rectangle stream.private java.awt.geom.AreareadRegion(java.io.DataInput pStream, java.awt.Rectangle pBounds)Read in a region.protected voidresetMembers()Resets all member variables.protected static voidshowIt(java.awt.image.BufferedImage pImage, java.lang.String pTitle)private voidverbosePolyCmd(java.lang.String pCmd, java.awt.Rectangle pBounds, java.awt.Polygon pPolygon)private voidverboseRegionCmd(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:ImageReaderBaseResets all member variables. This method is by default invoked from:- Specified by:
resetMembersin classImageReaderBase
-
getPICTFrame
private java.awt.Rectangle getPICTFrame() throws java.io.IOExceptionOpen 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.IOExceptionRead 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.IOExceptionReads 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.IOExceptionParse 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.IOExceptionReads the data following adirectBitsRectopcode.- 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.IOExceptionReads 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- ifpDestRectisnulljava.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.IOExceptionRead in a region. The input stream should be positioned at the first byte of the region.pBoundsis 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.IOExceptionRead 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:
readin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
getWidth
public int getWidth(int pIndex) throws java.io.IOException- Specified by:
getWidthin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
getHeight
public int getHeight(int pIndex) throws java.io.IOException- Specified by:
getHeightin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
getImageTypes
public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes(int imageIndex) throws java.io.IOException- Specified by:
getImageTypesin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
getImageMetadata
public javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex) throws java.io.IOExceptionDescription copied from class:ImageReaderBaseDefault implementation that always returnsnull.- Overrides:
getImageMetadatain 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)
-
-