org.hccp.util
Class ImageWriter

java.lang.Object
  |
  +--org.hccp.util.ImageWriter

public class ImageWriter
extends java.lang.Object

A utility for writing image formats to output streams in GIF and JPEG encodings. This class currently has an external dependency on the ACME Labs GIFEncoder.


Field Summary
static int GIF
           
static int JPEG
           
 
Constructor Summary
ImageWriter()
           
 
Method Summary
static void writeAsGif(java.awt.Image img, java.io.OutputStream os)
          encodes a java.awt.Image on the submitted java.io.OutputStream as a GIF.
static void writeAsJpeg(java.awt.Image img, java.io.OutputStream os)
          encodes a java.awt.image.BufferedImage on the submitted java.io.OutputStream as a JPEG.
static void writeImageToFile(java.awt.Image img, java.io.File f)
          Writes image to file of type JPEG or GIF based upon the filename extension of file.
static void writeImageToFile(java.awt.Image img, java.io.File f, int encoding)
          Writes image to file of type JPEG or GIF.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GIF

public static final int GIF
See Also:
Constant Field Values

JPEG

public static final int JPEG
See Also:
Constant Field Values
Constructor Detail

ImageWriter

public ImageWriter()
Method Detail

writeImageToFile

public static void writeImageToFile(java.awt.Image img,
                                    java.io.File f)
                             throws java.io.IOException
Writes image to file of type JPEG or GIF based upon the filename extension of file. Allows the following extensions in upper, lower, or mixed case: 'GIF', 'JPEG', and 'JPG'

Parameters:
img - the java.awt.Image instance to be encoded. For JPEG encoding this object must be an instance of java.awt.image.BufferedImage
f - the File to which this graph will be written to
Throws:
java.io.IOException

writeImageToFile

public static void writeImageToFile(java.awt.Image img,
                                    java.io.File f,
                                    int encoding)
                             throws java.io.IOException
Writes image to file of type JPEG or GIF.

Parameters:
img - the java.awt.Image instance to be encoded. For JPEG encoding this object must be an instance of java.awt.image.BufferedImage
f - the File to which this graph will be written to
encoding - an integer specifying the encoding for the target file. Available formats: GIF, JPEG
Throws:
java.io.IOException
See Also:
GIF, JPEG

writeAsGif

public static void writeAsGif(java.awt.Image img,
                              java.io.OutputStream os)
                       throws java.io.IOException
encodes a java.awt.Image on the submitted java.io.OutputStream as a GIF. Currently uses the the ACME Labs GIFEncoder.

Parameters:
img -
os -
Throws:
java.io.IOException

writeAsJpeg

public static void writeAsJpeg(java.awt.Image img,
                               java.io.OutputStream os)
                        throws java.io.IOException
encodes a java.awt.image.BufferedImage on the submitted java.io.OutputStream as a JPEG.

Parameters:
img - must be an instance of java.awt.image.BufferedImage
os -
Throws:
java.io.IOException