Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

non_com.media.jai.codec
Class PNMImageEncoder  view PNMImageEncoder download PNMImageEncoder.java

java.lang.Object
  extended bynon_com.media.jai.codec.ImageEncoderImpl
      extended bynon_com.media.jai.codec.PNMImageEncoder
All Implemented Interfaces:
ImageEncoder

public class PNMImageEncoder
extends ImageEncoderImpl

An ImageEncoder for the PNM family of file formats.

The PNM file format includes PBM for monochrome images, PGM for grey scale images, and PPM for color images. When writing the source data out, the encoder chooses the appropriate file variant based on the actual SampleModel of the source image. In case the source image data is unsuitable for the PNM file format, for example when source has 4 bands or float data type, the encoder throws an Error.

The raw file format is used wherever possible, unless the PNMEncodeParam object supplied to the constructor returns true from its getRaw() method.


Field Summary
private static java.lang.String COMMENT
           
private  byte[] lineSeparator
           
private  int maxValue
           
private static int PBM_ASCII
           
private static int PBM_RAW
           
private static int PGM_ASCII
           
private static int PGM_RAW
           
private static int PPM_ASCII
           
private static int PPM_RAW
           
private static int SPACE
           
private  int variant
           
 
Fields inherited from class non_com.media.jai.codec.ImageEncoderImpl
output, param
 
Constructor Summary
PNMImageEncoder(java.io.OutputStream output, ImageEncodeParam param)
          Constructor for the PNMImageEncoder object
 
Method Summary
 void encode(java.awt.image.RenderedImage im)
          Encodes a RenderedImage and writes the output to the OutputStream associated with this ImageEncoder.
private  boolean isRaw(int v)
          Returns true if file variant is raw format, false if ASCII.
private  void writeByte(java.io.OutputStream output, byte b)
          Writes a byte to the output in ASCII format.
private  void writeInteger(java.io.OutputStream output, int i)
          Writes an integer to the output in ASCII format.
 
Methods inherited from class non_com.media.jai.codec.ImageEncoderImpl
encode, getOutputStream, getParam, setParam
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PBM_ASCII

private static final int PBM_ASCII
See Also:
Constant Field Values

PGM_ASCII

private static final int PGM_ASCII
See Also:
Constant Field Values

PPM_ASCII

private static final int PPM_ASCII
See Also:
Constant Field Values

PBM_RAW

private static final int PBM_RAW
See Also:
Constant Field Values

PGM_RAW

private static final int PGM_RAW
See Also:
Constant Field Values

PPM_RAW

private static final int PPM_RAW
See Also:
Constant Field Values

SPACE

private static final int SPACE
See Also:
Constant Field Values

COMMENT

private static final java.lang.String COMMENT
See Also:
Constant Field Values

lineSeparator

private byte[] lineSeparator

variant

private int variant

maxValue

private int maxValue
Constructor Detail

PNMImageEncoder

public PNMImageEncoder(java.io.OutputStream output,
                       ImageEncodeParam param)
Constructor for the PNMImageEncoder object

Method Detail

encode

public void encode(java.awt.image.RenderedImage im)
            throws java.io.IOException
Encodes a RenderedImage and writes the output to the OutputStream associated with this ImageEncoder.

Specified by:
encode in interface ImageEncoder
Specified by:
encode in class ImageEncoderImpl

isRaw

private boolean isRaw(int v)
Returns true if file variant is raw format, false if ASCII.


writeInteger

private void writeInteger(java.io.OutputStream output,
                          int i)
                   throws java.io.IOException
Writes an integer to the output in ASCII format.


writeByte

private void writeByte(java.io.OutputStream output,
                       byte b)
                throws java.io.IOException
Writes a byte to the output in ASCII format.