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.
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 |
quality
public float quality
JPEGEncoder
public JPEGEncoder()
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.