loci.formats.in
Class PictReader

java.lang.Object
  extended by loci.formats.FormatHandler
      extended by loci.formats.FormatReader
          extended by loci.formats.in.PictReader
All Implemented Interfaces:
IFormatHandler, IFormatReader, StatusReporter

public class PictReader
extends FormatReader

PictReader is the file format reader for Apple PICT files. Most of this code was adapted from the PICT readers in JIMI (http://java.sun.com/products/jimi/index.html), ImageMagick (http://www.imagemagick.org), and Java QuickDraw.

Source code:
Trac, SVN


Field Summary
protected  byte[] bytes
          Pixel bytes.
protected  short[][] lookup
          Color lookup table for palette color images.
protected  int pictState
          Image state.
protected  LegacyQTTools qtTools
          Helper reader in case this one fails.
protected  RandomAccessStream ras
          Stream for reading pixel data.
protected  int rowBytes
          Number of bytes in a row of pixel data (variable).
protected  int state
          Decoder state.
protected  Vector strips
          Vector of byte arrays representing individual rows.
protected  boolean versionOne
          Whether or not the file is PICT v1.
 
Fields inherited from class loci.formats.FormatReader
collectMetadata, core, filterMetadata, group, in, metadata, metadataStore, normalizeData, saveOriginalMetadata, series, THUMBNAIL_DIMENSION
 
Fields inherited from class loci.formats.FormatHandler
currentId, debug, debugLevel, format, statusListeners, suffixes
 
Fields inherited from interface loci.formats.IFormatReader
CAN_GROUP, CANNOT_GROUP, MUST_GROUP
 
Constructor Summary
PictReader()
          Constructs a new PICT reader.
 
Method Summary
 Dimension getDimensions(byte[] stuff)
          Get the dimensions of a PICT file from the first 4 bytes after header.
protected  void initFile(String id)
          Initializes the given file (parsing header information, etc.).
 boolean isThisType(byte[] block)
          Checks if the given block is a valid header for this file format.
 BufferedImage open(byte[] pix)
          Open a PICT image from an array of bytes (used by OpenlabReader).
 byte[] openBytes(int no, byte[] buf)
          Obtains the specified image from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel).
 BufferedImage openImage(int no)
          Obtains the specified image from the current file.
 
Methods inherited from class loci.formats.FormatReader
addMeta, checkBytes, close, close, fileGroupOption, get16BitLookupTable, get8BitLookupTable, getChannelDimLengths, getChannelDimLengths, getChannelDimTypes, getChannelDimTypes, getCoreMetadata, getCoreMetadata, getCurrentFile, getDimensionOrder, getDimensionOrder, getEffectiveSizeC, getEffectiveSizeC, getImageCount, getImageCount, getIndex, getIndex, getMeta, getMetadata, getMetadata, getMetadataStore, getMetadataStore, getMetadataStoreRoot, getMetadataStoreRoot, getMetadataValue, getMetadataValue, getPixelType, getPixelType, getRGBChannelCount, getRGBChannelCount, getSeries, getSeries, getSeriesCount, getSeriesCount, getSizeC, getSizeC, getSizeT, getSizeT, getSizeX, getSizeX, getSizeY, getSizeY, getSizeZ, getSizeZ, getThumbSizeX, getThumbSizeX, getThumbSizeY, getThumbSizeY, getUsedFiles, getUsedFiles, getZCTCoords, getZCTCoords, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isInterleaved, isInterleaved, isLittleEndian, isLittleEndian, isMetadataCollected, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOrderCertain, isOriginalMetadataPopulated, isRGB, isRGB, isUsedFile, openBytes, openBytes, openBytes, openImage, openThumbBytes, openThumbBytes, openThumbImage, openThumbImage, setGroupFiles, setId, setMetadataCollected, setMetadataFiltered, setMetadataStore, setNormalized, setOriginalMetadataPopulated, setSeries, setSeries
 
Methods inherited from class loci.formats.FormatHandler
addStatusListener, debug, getFormat, getStatusListeners, getSuffixes, isThisType, isThisType, removeStatusListener, setDebug, setDebugLevel, setId, status, status, status, trace, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface loci.formats.IFormatHandler
getFormat, getSuffixes, isThisType, isThisType, setId
 
Methods inherited from interface loci.formats.StatusReporter
addStatusListener, getStatusListeners, removeStatusListener
 

Field Detail

ras

protected RandomAccessStream ras
Stream for reading pixel data.


bytes

protected byte[] bytes
Pixel bytes.


rowBytes

protected int rowBytes
Number of bytes in a row of pixel data (variable).


state

protected int state
Decoder state.


pictState

protected int pictState
Image state.


strips

protected Vector strips
Vector of byte arrays representing individual rows.


versionOne

protected boolean versionOne
Whether or not the file is PICT v1.


lookup

protected short[][] lookup
Color lookup table for palette color images.


qtTools

protected LegacyQTTools qtTools
Helper reader in case this one fails.

Constructor Detail

PictReader

public PictReader()
Constructs a new PICT reader.

Method Detail

getDimensions

public Dimension getDimensions(byte[] stuff)
                        throws FormatException
Get the dimensions of a PICT file from the first 4 bytes after header.

Throws:
FormatException

open

public BufferedImage open(byte[] pix)
                   throws FormatException,
                          IOException
Open a PICT image from an array of bytes (used by OpenlabReader).

Throws:
FormatException
IOException

isThisType

public boolean isThisType(byte[] block)
Description copied from interface: IFormatReader
Checks if the given block is a valid header for this file format.


openBytes

public byte[] openBytes(int no,
                        byte[] buf)
                 throws FormatException,
                        IOException
Description copied from interface: IFormatReader
Obtains the specified image from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel).

Parameters:
no - the image index within the file.
buf - a pre-allocated buffer.
Returns:
the pre-allocated buffer buf for convenience.
Throws:
FormatException - if there was a problem parsing the metadata of the file.
IOException - if there was a problem reading the file.

openImage

public BufferedImage openImage(int no)
                        throws FormatException,
                               IOException
Description copied from interface: IFormatReader
Obtains the specified image from the current file.

Specified by:
openImage in interface IFormatReader
Overrides:
openImage in class FormatReader
Throws:
FormatException
IOException

initFile

protected void initFile(String id)
                 throws FormatException,
                        IOException
Description copied from class: FormatReader
Initializes the given file (parsing header information, etc.). Most subclasses should override this method to perform initialization operations such as parsing metadata.

Overrides:
initFile in class FormatReader
Throws:
FormatException
IOException