jsky.image.fits.codec
Class FITSCodec

java.lang.Object
  extended by com.sun.media.jai.codec.ImageCodec
      extended by jsky.image.fits.codec.FITSCodec

public final class FITSCodec
extends com.sun.media.jai.codec.ImageCodec

A subclass of ImageCodec that handles the FITS image format.

Version:
$Revision: 1.1 $
Author:
Allan Brighton

Constructor Summary
FITSCodec()
          Constructs an instance of FITSCodec.
 
Method Summary
 boolean canEncodeImage(java.awt.image.RenderedImage im, com.sun.media.jai.codec.ImageEncodeParam param)
          Returns true if the image is encodable by this codec.
protected  com.sun.media.jai.codec.ImageDecoder createImageDecoder(java.io.InputStream src, com.sun.media.jai.codec.ImageDecodeParam param)
          Instantiates a FITSDecoder to read from the given InputStream.
protected  com.sun.media.jai.codec.ImageDecoder createImageDecoder(com.sun.media.jai.codec.SeekableStream src, com.sun.media.jai.codec.ImageDecodeParam param)
          Instantiates a FITSDecoder to read from the given SeekableStream.
protected  com.sun.media.jai.codec.ImageEncoder createImageEncoder(java.io.OutputStream dst, com.sun.media.jai.codec.ImageEncodeParam param)
          Instantiates a FITSEncoder to write to the given OutputStream.
 java.lang.Class getDecodeParamClass()
          Returns Object.class since no DecodeParam object is required for decoding.
 java.lang.Class getEncodeParamClass()
          Returns null since no encoder exists.
 java.lang.String getFormatName()
          Returns the name of the format handled by this codec.
 int getNumHeaderBytes()
          Returns the number of bytes from the beginning of the data required to recognize it as being in FITS format.
 boolean isFormatRecognized(byte[] header)
          Returns true if the header bytes indicate FITS format.
 
Methods inherited from class com.sun.media.jai.codec.ImageCodec
createComponentColorModel, createComponentColorModel, createGrayIndexColorModel, createImageDecoder, createImageDecoder, createImageDecoder, createImageDecoder, createImageEncoder, getCodec, getCodecs, getDecoderNames, getEncoderNames, isFormatRecognized, isIndicesForGrayscale, registerCodec, unregisterCodec
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FITSCodec

public FITSCodec()
Constructs an instance of FITSCodec.

Method Detail

getFormatName

public java.lang.String getFormatName()
Returns the name of the format handled by this codec.

Specified by:
getFormatName in class com.sun.media.jai.codec.ImageCodec

getDecodeParamClass

public java.lang.Class getDecodeParamClass()
Returns Object.class since no DecodeParam object is required for decoding.

Specified by:
getDecodeParamClass in class com.sun.media.jai.codec.ImageCodec

getEncodeParamClass

public java.lang.Class getEncodeParamClass()
Returns null since no encoder exists.

Specified by:
getEncodeParamClass in class com.sun.media.jai.codec.ImageCodec

canEncodeImage

public boolean canEncodeImage(java.awt.image.RenderedImage im,
                              com.sun.media.jai.codec.ImageEncodeParam param)
Returns true if the image is encodable by this codec.

Specified by:
canEncodeImage in class com.sun.media.jai.codec.ImageCodec

createImageEncoder

protected com.sun.media.jai.codec.ImageEncoder createImageEncoder(java.io.OutputStream dst,
                                                                  com.sun.media.jai.codec.ImageEncodeParam param)
Instantiates a FITSEncoder to write to the given OutputStream.

Specified by:
createImageEncoder in class com.sun.media.jai.codec.ImageCodec
Parameters:
dst - the OutputStream to write to.
param - an instance of FITSEncodeParam used to control the encoding process, or null. A ClassCastException will be thrown if param is non-null but not an instance of FITSEncodeParam.

createImageDecoder

protected com.sun.media.jai.codec.ImageDecoder createImageDecoder(java.io.InputStream src,
                                                                  com.sun.media.jai.codec.ImageDecodeParam param)
Instantiates a FITSDecoder to read from the given InputStream.

By overriding this method, FITSCodec is able to ensure that a ForwardSeekableStream is used to wrap the source InputStream instead of the a general (and more expensive) subclass of SeekableStream. Since the FITS decoder does not require the ability to seek backwards in its input, this allows for greater efficiency.

Overrides:
createImageDecoder in class com.sun.media.jai.codec.ImageCodec
Parameters:
src - the InputStream to read from.
param - an instance of ImageDecodeParam used to control the decoding process, or null.

createImageDecoder

protected com.sun.media.jai.codec.ImageDecoder createImageDecoder(com.sun.media.jai.codec.SeekableStream src,
                                                                  com.sun.media.jai.codec.ImageDecodeParam param)
Instantiates a FITSDecoder to read from the given SeekableStream.

Specified by:
createImageDecoder in class com.sun.media.jai.codec.ImageCodec
Parameters:
src - the SeekableStream to read from.
param - an instance of ImageDecodeParam used to control the decoding process, or null.

getNumHeaderBytes

public int getNumHeaderBytes()
Returns the number of bytes from the beginning of the data required to recognize it as being in FITS format.

Overrides:
getNumHeaderBytes in class com.sun.media.jai.codec.ImageCodec

isFormatRecognized

public boolean isFormatRecognized(byte[] header)
Returns true if the header bytes indicate FITS format.

Overrides:
isFormatRecognized in class com.sun.media.jai.codec.ImageCodec
Parameters:
header - an array of bytes containing the initial bytes of the input data.