JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing.encode
Class JPEGEncoder

java.lang.Object
  |
  +--com.klg.jclass.util.swing.encode.AbstractImageEncoder
        |
        +--com.klg.jclass.util.swing.encode.JPEGEncoder
All Implemented Interfaces:
Encoder

public class JPEGEncoder
extends AbstractImageEncoder

This class encodes a JPEG file from an Image to an OutputStream. It uses the sun com.sun.image.codec.jpeg package to do the encoding, and hence is usable only under jdk 1.2.2 or later.


Field Summary
 float quality
           
 
Constructor Summary
JPEGEncoder()
           
 
Method Summary
 float getQuality()
          Get quality factor for JPEG encoding.
 void saveImage(Image img, OutputStream ofile)
           
 void setQuality(float qlty)
          Set quality factor for JPEG encoding.
 
Methods inherited from class com.klg.jclass.util.swing.encode.AbstractImageEncoder
byteFromChar, byteFromInt, bytesFromInt, bytesFromLong, compressColor, compressColor, createByte, encode, encode, error, snapshot, snapshotJava3d
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

quality

public float quality
Constructor Detail

JPEGEncoder

public JPEGEncoder()
Method Detail

saveImage

public void saveImage(Image img,
                      OutputStream ofile)
               throws IOException,
                      EncoderException
Specified by:
saveImage in class AbstractImageEncoder
IOException
EncoderException

getQuality

public float getQuality()
Get quality factor for JPEG encoding. The quality factor is a floating point number between 0 and 1. A value of 1 provides the best quality image but features the words compression. A value of 0 provides the best compression but the worst quality image.

Returns:
qlty The quality factor being used. Must be between 0 and 1.

setQuality

public void setQuality(float qlty)
Set quality factor for JPEG encoding. The quality factor is a floating point number between 0 and 1. A value of 1 provides the best quality image but features the words compression. A value of 0 provides the best compression but the worst quality image.

Parameters:
qlty - The quality factor to set. Must be between 0 and 1. If outside these ranges, the value will be clipped to 0 or 1.

Copyright © 2004 Quest Software Inc..
All rights reserved.