UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.awt.image
Class ImageEncoder

java.lang.Object
  |
  +--edu.berkeley.guir.lib.awt.image.ImageEncoder
All Implemented Interfaces:
ImageConsumer
Direct Known Subclasses:
GifEncoder

public abstract class ImageEncoder
extends Object
implements ImageConsumer

Abstract class for writing out an image.

A framework for classes that encode and write out an image in a particular file format.

This provides a simplified rendition of the ImageConsumer interface. It always delivers the pixels as ints in the RGBdefault color model. It always provides them in top-down left-right order. If you want more flexibility you can always implement ImageConsumer directly.

Fetch the software.
Fetch the entire Acme package.

See Also:
GifEncoder, ImageDecoder

Field Summary
protected  OutputStream out
           
 
Fields inherited from interface java.awt.image.ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
 
Constructor Summary
ImageEncoder(Image img, OutputStream out)
          Constructor.
ImageEncoder(ImageProducer producer, OutputStream out)
          Constructor.
 
Method Summary
 void encode()
          Call this after initialization to get things going.
 void imageComplete(int status)
           
 void setColorModel(ColorModel model)
           
 void setDimensions(int width, int height)
           
 void setHints(int hintflags)
           
 void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize)
           
 void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)
           
 void setProperties(Hashtable props)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected OutputStream out
Constructor Detail

ImageEncoder

public ImageEncoder(Image img,
                    OutputStream out)
             throws IOException
Constructor.
Parameters:
img - The image to encode.
out - The stream to write the bytes to.

ImageEncoder

public ImageEncoder(ImageProducer producer,
                    OutputStream out)
             throws IOException
Constructor.
Parameters:
producer - The ImageProducer to encode.
out - The stream to write the bytes to.
Method Detail

encode

public void encode()
            throws IOException
Call this after initialization to get things going.

setDimensions

public void setDimensions(int width,
                          int height)
Specified by:
setDimensions in interface ImageConsumer

setProperties

public void setProperties(Hashtable props)
Specified by:
setProperties in interface ImageConsumer

setColorModel

public void setColorModel(ColorModel model)
Specified by:
setColorModel in interface ImageConsumer

setHints

public void setHints(int hintflags)
Specified by:
setHints in interface ImageConsumer

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      ColorModel model,
                      byte[] pixels,
                      int off,
                      int scansize)
Specified by:
setPixels in interface ImageConsumer

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      ColorModel model,
                      int[] pixels,
                      int off,
                      int scansize)
Specified by:
setPixels in interface ImageConsumer

imageComplete

public void imageComplete(int status)
Specified by:
imageComplete in interface ImageConsumer

Copyright Information