uk.ac.starlink.jaiutil
Class HDXCodec

java.lang.Object
  extended by com.sun.media.jai.codec.ImageCodec
      extended by uk.ac.starlink.jaiutil.HDXCodec

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

A subclass of ImageCodec that handles HDX encapsulated data.

Version:
$Id$
Author:
Allan Brighton, Peter W. Draper

Constructor Summary
HDXCodec()
          Constructs an instance of HDXCodec.
 
Method Summary
 boolean canEncodeImage(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(InputStream src, com.sun.media.jai.codec.ImageDecodeParam param)
          Instantiates a HDXDecoder 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 HDXDecoder to read from the given SeekableStream.
protected  com.sun.media.jai.codec.ImageEncoder createImageEncoder(OutputStream dst, com.sun.media.jai.codec.ImageEncodeParam param)
          Instantiates a HDXEncoder to write to the given OutputStream.
 Class getDecodeParamClass()
          Returns Object.class since no DecodeParam object is required for decoding.
 Class getEncodeParamClass()
          Returns null since no encoder exists.
 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 XML 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

HDXCodec

public HDXCodec()
Constructs an instance of HDXCodec.

Method Detail

getFormatName

public 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 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 Class getEncodeParamClass()
Returns null since no encoder exists. TODO: HDX should be able to save itself.

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

canEncodeImage

public boolean canEncodeImage(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(OutputStream dst,
                                                                  com.sun.media.jai.codec.ImageEncodeParam param)
Instantiates a HDXEncoder 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 HDXEncodeParam used to control the encoding process, or null. A ClassCastException will be thrown if param is non-null but not an instance of HDXEncodeParam.

createImageDecoder

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

By overriding this method, HDXCodec 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 HDX decoder does not require the ability to seek backwards in its input, this allows for greater efficiency (TODO: not very problematic for HDX cf. FITS).

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 HDXDecoder 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 XML format. All XML files are assumed to have some HDX content.

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


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.