Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.pearsoneduc.ip.io
Class PPMDecoder

    java.lang.Object
      |
      +--com.pearsoneduc.ip.io.PPMDecoder

public class PPMDecoder
extends java.lang.Object
implements ImageDecoder, PPMConstants

Reads image data in the PBM, PGM or PPM format from a stream or a file. Documentation for the `PPMEncoder` class contains further information on these formats. Note that only the ASCII variants can be decoded.

Example of use:

         PPMDecoder ppm = new PPMDecoder(inputFile);
         BufferedImage image = ppm.decodeAsBufferedImage();

Version:
  1.1 [1999/06/27]
Author:
  Nick Efford
See Also:
  `PPMDecoderException`, `PPMEncoder`, `BufferedImage`

Constructor Summary
`PPMDecoder()` Constructs a PPMDecoder associated with standard input.
`PPMDecoder(java.io.InputStream in)` Constructs a PPMDecoder that reads from an existing InputStream.
`PPMDecoder(java.lang.String imgfile)` Constructs a PPMDecoder that reads from a named file.

Method Summary
`boolean` | `bitmapInversionEnabled()` Indicates whether a binary image will be inverted on input, such that 1 becomes black and 0 becomes white.
`java.awt.image.BufferedImage` | `decodeAsBufferedImage()` Decodes the input data and creates an image.
`void` | `disableBitmapInversion()` Disables bitmap inversion when reading data in the PBM format.
`void` | `enableBitmapInversion()` Enables bitmap inversion when reading data in the PBM format.
`int` | `getHeight()`
`int` | `getMaxValue()`
`int` | `getNumPixels()`
`int` | `getType()` Indicates what type of image is available for decoding.
`int` | `getWidth()`
`boolean` | `isBinary()` Indicates whether binary image data are available for decoding.
`boolean` | `isGrey()` Indicates whether greyscale image data are available for decoding.
`boolean` | `isRGB()` Indicates whether RGB image data are available for decoding.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PPMDecoder

    public PPMDecoder()
               throws java.io.IOException,
                      PPMDecoderException

  Constructs a PPMDecoder associated with standard input.
  Throws:
    java.io.IOException - if there was a problem reading data from standard input.
    PPMDecoderException - if the data are not in a valid PBM, PGM or PPM format.

### PPMDecoder

    public PPMDecoder(java.io.InputStream in)
               throws java.io.IOException,
                      PPMDecoderException

  Constructs a PPMDecoder that reads from an existing InputStream.
  Parameters:
    `in` - InputStream representing the source of image data
  Throws:
    java.io.IOException - if there was a problem reading data from the stream.
    PPMDecoderException - if the data are not in a valid PBM, PGM or PPM format.

### PPMDecoder

    public PPMDecoder(java.lang.String imgfile)
               throws java.io.IOException,
                      PPMDecoderException

  Constructs a PPMDecoder that reads from a named file.
  Parameters:
    `imgfile` - name of the file containing the image data
  Throws:
    java.io.IOException - if the file does not exist or there was a problem reading data from it.
    PPMDecoderException - if the data are not in a valid PBM, PGM or PPM format.

Method Detail

### getType

    public int getType()

  Indicates what type of image is available for decoding.
  Returns:
    one of the constants TYPE_UNKNOWN, TYPE_PBM, TYPE_PGM and TYPE_PPM, defined in the PPMConstants interface.
  See Also:
    `PPMConstants`

### isBinary

    public boolean isBinary()

  Indicates whether binary image data are available for decoding.
  Returns:
    true if a binary image is available, false otherwise.

### isGrey

    public boolean isGrey()

  Indicates whether greyscale image data are available for decoding.
  Returns:
    true if a greyscale image is available, false otherwise.

### isRGB

    public boolean isRGB()

  Indicates whether RGB image data are available for decoding.
  Returns:
    true if a colour image is available, false otherwise.

### getWidth

    public int getWidth()

  Returns:
    width of image to be decoded.

### getHeight

    public int getHeight()

  Returns:
    height of image to be decoded.

### getNumPixels

    public int getNumPixels()

  Returns:
    number of pixels in image to be decoded.

### getMaxValue

    public int getMaxValue()

  Returns:
    maximum pixel value possible in image to be decoded.

### bitmapInversionEnabled

    public boolean bitmapInversionEnabled()

  Indicates whether a binary image will be inverted on input, such that 1 becomes black and 0 becomes white.
  Returns:
    true if the data will be inverted, false otherwise.

### disableBitmapInversion

    public void disableBitmapInversion()

  Disables bitmap inversion when reading data in the PBM format.

### enableBitmapInversion

    public void enableBitmapInversion()

  Enables bitmap inversion when reading data in the PBM format.

### decodeAsBufferedImage

    public java.awt.image.BufferedImage decodeAsBufferedImage()
                                                       throws java.io.IOException,
                                                              PPMDecoderException

  Decodes the input data and creates an image.
  Specified by:
    decodeAsBufferedImage in interface ImageDecoder
  Returns:
    a BufferedImage containing the data.
  Throws:
    java.io.IOException - if there was a problem reading the data.
    PPMDecoderException - if the data were not formatted correctly.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD