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

Quick Search    Search Deep

Acme.JPM.Encoders
Class ImageEncoder  view ImageEncoder download ImageEncoder.java

java.lang.Object
  extended byAcme.JPM.Encoders.ImageEncoder
All Implemented Interfaces:
java.awt.image.ImageConsumer
Direct Known Subclasses:
GifEncoder, PpmEncoder

public abstract class ImageEncoder
extends java.lang.Object
implements java.awt.image.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.


Field Summary
private  boolean accumulate
           
private  int[] accumulator
           
private  boolean encoding
           
private  int height
           
private  int hintflags
           
private  java.io.IOException iox
           
protected  java.io.OutputStream out
           
private  java.awt.image.ImageProducer producer
           
private  java.util.Hashtable props
           
private static java.awt.image.ColorModel rgbModel
           
private  boolean started
           
private  int width
           
 
Fields inherited from interface java.awt.image.ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
 
Constructor Summary
ImageEncoder(java.awt.Image img, java.io.OutputStream out)
           
ImageEncoder(java.awt.image.ImageProducer producer, java.io.OutputStream out)
           
 
Method Summary
 void encode()
           
(package private) abstract  void encodeDone()
           
private  void encodeFinish()
           
(package private) abstract  void encodePixels(int x, int y, int w, int h, int[] rgbPixels, int off, int scansize)
           
private  void encodePixelsWrapper(int x, int y, int w, int h, int[] rgbPixels, int off, int scansize)
           
(package private) abstract  void encodeStart(int w, int h)
           
 void imageComplete(int status)
          The ImageProducer calls this method to indicate a single frame or the entire image is complete.
 void setColorModel(java.awt.image.ColorModel model)
          This ColorModel should indicate the model used by the majority of calls to setPixels.
 void setDimensions(int width, int height)
          An ImageProducer indicates the size of the image being produced using this method.
 void setHints(int hintflags)
          The ImageProducer should call this method with a bit mask of hints from any of RANDOMPIXELORDER, TOPDOWNLEFTRIGHT, COMPLETESCANLINES, SINGLEPASS, SINGLEFRAME.
 void setPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, byte[] pixels, int off, int scansize)
          Deliver a subset of an ImageProducer's pixels to this ImageConsumer.
 void setPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, int[] pixels, int off, int scansize)
          Deliver a subset of an ImageProducer's pixels to this ImageConsumer.
 void setProperties(java.util.Hashtable props)
          An ImageProducer can set a list of properties associated with this image by using this method.
private  void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rgbModel

private static final java.awt.image.ColorModel rgbModel

out

protected java.io.OutputStream out

props

private java.util.Hashtable props

iox

private java.io.IOException iox

producer

private java.awt.image.ImageProducer producer

accumulator

private int[] accumulator

accumulate

private boolean accumulate

encoding

private boolean encoding

started

private boolean started

height

private int height

hintflags

private int hintflags

width

private int width
Constructor Detail

ImageEncoder

public ImageEncoder(java.awt.Image img,
                    java.io.OutputStream out)
             throws java.io.IOException

ImageEncoder

public ImageEncoder(java.awt.image.ImageProducer producer,
                    java.io.OutputStream out)
             throws java.io.IOException
Method Detail

setColorModel

public void setColorModel(java.awt.image.ColorModel model)
Description copied from interface: java.awt.image.ImageConsumer
This ColorModel should indicate the model used by the majority of calls to setPixels. Each call to setPixels could however indicate a different ColorModel.

Specified by:
setColorModel in interface java.awt.image.ImageConsumer

setDimensions

public void setDimensions(int width,
                          int height)
Description copied from interface: java.awt.image.ImageConsumer
An ImageProducer indicates the size of the image being produced using this method.

Specified by:
setDimensions in interface java.awt.image.ImageConsumer

setHints

public void setHints(int hintflags)
Description copied from interface: java.awt.image.ImageConsumer
The ImageProducer should call this method with a bit mask of hints from any of RANDOMPIXELORDER, TOPDOWNLEFTRIGHT, COMPLETESCANLINES, SINGLEPASS, SINGLEFRAME.

Specified by:
setHints in interface java.awt.image.ImageConsumer

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      java.awt.image.ColorModel model,
                      byte[] pixels,
                      int off,
                      int scansize)
Description copied from interface: java.awt.image.ImageConsumer
Deliver a subset of an ImageProducer's pixels to this ImageConsumer. Each element of the pixels array represents one pixel. The pixel data is formatted according to the color model model. The x and y parameters are the coordinates of the block of pixels being delivered to this ImageConsumer. They are specified relative to the top left corner of the image being produced. Likewise, w and h are the pixel block's dimensions.

Specified by:
setPixels in interface java.awt.image.ImageConsumer

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      java.awt.image.ColorModel model,
                      int[] pixels,
                      int off,
                      int scansize)
Description copied from interface: java.awt.image.ImageConsumer
Deliver a subset of an ImageProducer's pixels to this ImageConsumer. Each element of the pixels array represents one pixel. The pixel data is formatted according to the color model model. The x and y parameters are the coordinates of the rectangular region of pixels being delivered to this ImageConsumer, specified relative to the top left corner of the image being produced. Likewise, w and h are the pixel region's dimensions.

Specified by:
setPixels in interface java.awt.image.ImageConsumer

setProperties

public void setProperties(java.util.Hashtable props)
Description copied from interface: java.awt.image.ImageConsumer
An ImageProducer can set a list of properties associated with this image by using this method.

Specified by:
setProperties in interface java.awt.image.ImageConsumer

encode

public void encode()
            throws java.io.IOException

imageComplete

public void imageComplete(int status)
Description copied from interface: java.awt.image.ImageConsumer
The ImageProducer calls this method to indicate a single frame or the entire image is complete. The method is also used to indicate an error in loading or producing the image.

Specified by:
imageComplete in interface java.awt.image.ImageConsumer

encodeDone

abstract void encodeDone()
                  throws java.io.IOException

encodePixels

abstract void encodePixels(int x,
                           int y,
                           int w,
                           int h,
                           int[] rgbPixels,
                           int off,
                           int scansize)
                    throws java.io.IOException

encodeStart

abstract void encodeStart(int w,
                          int h)
                   throws java.io.IOException

encodeFinish

private void encodeFinish()
                   throws java.io.IOException

encodePixelsWrapper

private void encodePixelsWrapper(int x,
                                 int y,
                                 int w,
                                 int h,
                                 int[] rgbPixels,
                                 int off,
                                 int scansize)
                          throws java.io.IOException

stop

private void stop()