com.pearsoneduc.ip.io
Class SIFDecoder
java.lang.Object
|
+--com.pearsoneduc.ip.io.SIFDecoder
- public class SIFDecoder
- extends java.lang.Object
- implements ImageDecoder, SIFConstants
Reads image data in SIF format from a stream or a file.
Documentation for the SIFEncoder
class gives further
details of this format.
- Version:
- 1.0 [1999/01/30]
- Author:
- Nick Efford
- See Also:
SIFDecoderException
,
SIFEncoder
,
BufferedImage
Constructor Summary |
SIFDecoder()
Constructs a SIFDecoder associated with the standard input. |
SIFDecoder(java.io.InputStream in)
Constructs a SIFDecoder from an existing InputStream. |
SIFDecoder(java.lang.String imgfile)
Constructs a SIFDecoder that reads from a named file. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
SIFDecoder
public SIFDecoder()
throws java.io.IOException,
SIFDecoderException
- Constructs a SIFDecoder associated with the standard input.
- Throws:
- java.io.IOException - if bytes cannot be read from standard input.
- SIFDecoderException - if the data available via standard
input are not in SIF format.
SIFDecoder
public SIFDecoder(java.io.InputStream in)
throws java.io.IOException,
SIFDecoderException
- Constructs a SIFDecoder from an existing InputStream.
- Parameters:
in
- An InputStream object- Throws:
- java.io.IOException - if bytes cannot be read from the stream.
- SIFDecoderException - if the data available on the stream
are not in SIF format.
SIFDecoder
public SIFDecoder(java.lang.String imgfile)
throws java.io.IOException,
SIFDecoderException
- Constructs a SIFDecoder that reads from a named file.
- Parameters:
imgfile
- name of the file containing image data- Throws:
- java.io.IOException - if the file does not exist or data cannot
be read from it.
- SIFDecoderException - if the contents of the file are not
in SIF format.
getSignatureString
public java.lang.String getSignatureString()
- Creates a String representing the signature (first four bytes)
of the data on the input stream.
- Returns:
- String representing an image signature.
getWidth
public int getWidth()
- Returns:
- width of the image to be decoded.
getHeight
public int getHeight()
- Returns:
- height of the image to be decoded.
getNumPixels
public int getNumPixels()
- Returns:
- number of pixels in the image to be decoded.
getType
public int getType()
- Returns:
- code signifying image type - either
BufferedImage.TYPE_BYTE_GRAY
or BufferedImage.TYPE_3BYTE_BGR.
getNumBands
public int getNumBands()
- Determines the number of bands in the image data available on
the input stream. This will be 3 for colour images, 1 for
greyscale images or 0 otherwise.
- Returns:
- number of bands.
isGrey
public boolean isGrey()
- Returns:
- true if the image is an 8-bit greyscale image, false otherwise.
isRGB
public boolean isRGB()
- Returns:
- true if the image is a 24-bit RGB image, false otherwise.
isCompressed
public boolean isCompressed()
- Returns:
- true if image data are compressed, false otherwise.
decodeAsBufferedImage
public java.awt.image.BufferedImage decodeAsBufferedImage()
throws java.io.IOException
- Reads image data from a stream.
- Specified by:
- decodeAsBufferedImage in interface ImageDecoder
- Returns:
- a BufferedImage containing data read from the stream.
- Throws:
- java.io.IOException - If there is an error while reading
image data (e.g. premature end of file).
- See Also:
BufferedImage