loci.formats
Class PictReader

java.lang.Object
  extended byloci.formats.FormatHandler
      extended byloci.formats.FormatReader
          extended byloci.formats.PictReader

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.


Field Summary
protected  byte[] bytes
          Pixel bytes.
protected  int height
          Height of the image.
protected  RandomAccessFile in
          Current file.
protected  boolean little
          Flag indicating whether current file is little endian.
protected  short[][] lookup
          Color lookup table for palette color images.
protected  int pictState
          Image state.
protected  int pt
          Pointer into the array of bytes representing the file.
protected  LegacyQTReader qtReader
          Helper reader in case this one fails.
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.
protected  int width
          Width of the image.
 
Fields inherited from class loci.formats.FormatReader
DEBUG, DEBUG_LEVEL, metadata, ome
 
Fields inherited from class loci.formats.FormatHandler
chooser, currentId, filters, format, suffixes
 
Constructor Summary
PictReader()
          Constructs a new PICT reader.
 
Method Summary
 void close()
          Closes any open files.
 Dimension getDimensions(byte[] stuff)
          Get the dimensions of a PICT file from the first 4 bytes after header.
 int getImageCount(String id)
          Determines the number of images in the given PICT file.
protected  void initFile(String id)
          Initializes the given PICT file.
 boolean isThisType(byte[] block)
          Checks if the given block is a valid header for a PICT file.
static void main(String[] args)
           
 BufferedImage open(String id, int no)
          Obtains the specified image from the given PICT file.
 BufferedImage openBytes(byte[] pix)
          Open a PICT image from an array of bytes (used by OpenlabReader).
 
Methods inherited from class loci.formats.FormatReader
createFilters, getMetadata, getMetadataValue, getOMENode, open, testRead
 
Methods inherited from class loci.formats.FormatHandler
getFileChooser, getFileFilters, getFormat, getSuffixes, isThisType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

protected RandomAccessFile in
Current file.


little

protected boolean little
Flag indicating whether current file is little endian.


bytes

protected byte[] bytes
Pixel bytes.


width

protected int width
Width of the image.


height

protected int height
Height of the image.


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.


pt

protected int pt
Pointer into the array of bytes representing the file.


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.


qtReader

protected LegacyQTReader qtReader
Helper reader in case this one fails.

Constructor Detail

PictReader

public PictReader()
Constructs a new PICT reader.

Method Detail

isThisType

public boolean isThisType(byte[] block)
Checks if the given block is a valid header for a PICT file.

Specified by:
isThisType in class FormatReader

getImageCount

public int getImageCount(String id)
                  throws FormatException,
                         IOException
Determines the number of images in the given PICT file.

Specified by:
getImageCount in class FormatReader
Throws:
FormatException
IOException

open

public BufferedImage open(String id,
                          int no)
                   throws FormatException,
                          IOException
Obtains the specified image from the given PICT file.

Specified by:
open in class FormatReader
Throws:
FormatException
IOException

close

public void close()
           throws FormatException,
                  IOException
Closes any open files.

Specified by:
close in class FormatReader
Throws:
FormatException
IOException

initFile

protected void initFile(String id)
                 throws FormatException,
                        IOException
Initializes the given PICT file.

Overrides:
initFile in class FormatReader
Throws:
FormatException
IOException

getDimensions

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

Throws:
FormatException

openBytes

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

Throws:
FormatException

main

public static void main(String[] args)
                 throws FormatException,
                        IOException
Throws:
FormatException
IOException