Back to index

moin  1.9.0~rc2
Public Member Functions | Protected Attributes | Package Functions | Private Member Functions | Private Attributes | Static Private Attributes
Acme.JPM.Encoders.ImageEncoder Class Reference

Abstract class for writing out an image. More...

Inheritance diagram for Acme.JPM.Encoders.ImageEncoder:
Inheritance graph
[legend]
Collaboration diagram for Acme.JPM.Encoders.ImageEncoder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ImageEncoder (Image img, OutputStream out) throws IOException
 Constructor.
 ImageEncoder (ImageProducer producer, OutputStream out) throws IOException
 Constructor.
synchronized void encode () throws IOException
 Call this after initialization to get things going.
void setDimensions (int width, int height)
void setProperties (Hashtable props)
void setColorModel (ColorModel model)
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 imageComplete (int status)

Protected Attributes

OutputStream out

Package Functions

abstract void encodeStart (int w, int h) throws IOException
 Subclasses implement this to initialize an encoding.
abstract void encodePixels (int x, int y, int w, int h, int[] rgbPixels, int off, int scansize) throws IOException
 Subclasses implement this to actually write out some bits. They.
abstract void encodeDone () throws IOException
 Subclasses implement this to finish an encoding.

Private Member Functions

void encodePixelsWrapper (int x, int y, int w, int h, int[] rgbPixels, int off, int scansize) throws IOException
void encodeFinish () throws IOException
synchronized void stop ()

Private Attributes

ImageProducer producer
int width = -1
int height = -1
int hintflags = 0
boolean started = false
boolean encoding
IOException iox
Hashtable props = null
boolean accumulate = false
int[] accumulator

Static Private Attributes

static final ColorModel rgbModel = ColorModel.getRGBdefault()

Detailed Description

Abstract class for writing out an image.

Definition at line 55 of file ImageEncoder.java.


Constructor & Destructor Documentation

Acme.JPM.Encoders.ImageEncoder.ImageEncoder ( Image  img,
OutputStream  out 
) throws IOException [inline]

Constructor.

Definition at line 73 of file ImageEncoder.java.

       {
       this( img.getSource(), out );
       }
Acme.JPM.Encoders.ImageEncoder.ImageEncoder ( ImageProducer  producer,
OutputStream  out 
) throws IOException [inline]

Constructor.

Definition at line 81 of file ImageEncoder.java.

       {
       this.producer = producer;
       this.out = out;
       }

Member Function Documentation

synchronized void Acme.JPM.Encoders.ImageEncoder.encode ( ) throws IOException [inline]

Call this after initialization to get things going.

Definition at line 108 of file ImageEncoder.java.

       {
       encoding = true;
       iox = null;
       producer.startProduction( this );
       while ( encoding )
           try
              {
              wait();
              }
           catch ( InterruptedException e ) {}
       if ( iox != null )
           throw iox;
       }
abstract void Acme.JPM.Encoders.ImageEncoder.encodeDone ( ) throws IOException [package, pure virtual]

Subclasses implement this to finish an encoding.

Implemented in Acme.JPM.Encoders.GifEncoder.

Here is the caller graph for this function:

void Acme.JPM.Encoders.ImageEncoder.encodeFinish ( ) throws IOException [inline, private]

Definition at line 150 of file ImageEncoder.java.

       {
       if ( accumulate )
           {
           encodePixels( 0, 0, width, height, accumulator, 0, width );
           accumulator = null;
           accumulate = false;
           }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

abstract void Acme.JPM.Encoders.ImageEncoder.encodePixels ( int  x,
int  y,
int  w,
int  h,
int[]  rgbPixels,
int  off,
int  scansize 
) throws IOException [package, pure virtual]

Subclasses implement this to actually write out some bits. They.

Implemented in Acme.JPM.Encoders.GifEncoder.

Here is the caller graph for this function:

void Acme.JPM.Encoders.ImageEncoder.encodePixelsWrapper ( int  x,
int  y,
int  w,
int  h,
int[]  rgbPixels,
int  off,
int  scansize 
) throws IOException [inline, private]

Definition at line 126 of file ImageEncoder.java.

       {
       if ( ! started )
           {
           started = true;
           encodeStart( width, height );
           if ( ( hintflags & TOPDOWNLEFTRIGHT ) == 0 )
              {
              accumulate = true;
              accumulator = new int[width * height];
              }
           }
       if ( accumulate )
           for ( int row = 0; row < h; ++row )
              System.arraycopy(
                  rgbPixels, row * scansize + off,
                  accumulator, ( y + row ) * width + x,
                  w );
       else
           encodePixels( x, y, w, h, rgbPixels, off, scansize );
       }

Here is the call graph for this function:

Here is the caller graph for this function:

abstract void Acme.JPM.Encoders.ImageEncoder.encodeStart ( int  w,
int  h 
) throws IOException [package, pure virtual]

Subclasses implement this to initialize an encoding.

Implemented in Acme.JPM.Encoders.GifEncoder.

Here is the caller graph for this function:

void Acme.JPM.Encoders.ImageEncoder.imageComplete ( int  status) [inline]

Definition at line 252 of file ImageEncoder.java.

       {
       producer.removeConsumer( this );
       if ( status == ImageConsumer.IMAGEABORTED )
           iox = new IOException( "image aborted" );
       else
           {
           try
              {
              encodeFinish();
              encodeDone();
              }
           catch ( IOException e )
              {
              iox = e;
              }
           }
       stop();
       }

Here is the call graph for this function:

void Acme.JPM.Encoders.ImageEncoder.setColorModel ( ColorModel  model) [inline]

Definition at line 180 of file ImageEncoder.java.

       {
       // Ignore.
       }
void Acme.JPM.Encoders.ImageEncoder.setDimensions ( int  width,
int  height 
) [inline]

Definition at line 169 of file ImageEncoder.java.

       {
       this.width = width;
       this.height = height;
       }
void Acme.JPM.Encoders.ImageEncoder.setHints ( int  hintflags) [inline]

Definition at line 185 of file ImageEncoder.java.

       {
       this.hintflags = hintflags;
       }
void Acme.JPM.Encoders.ImageEncoder.setPixels ( int  x,
int  y,
int  w,
int  h,
ColorModel  model,
byte[]  pixels,
int  off,
int  scansize 
) [inline]

Definition at line 190 of file ImageEncoder.java.

       {
       int[] rgbPixels = new int[w];
       for ( int row = 0; row < h; ++row )
           {
           int rowOff = off + row * scansize;
           for ( int col = 0; col < w; ++col )
              rgbPixels[col] = model.getRGB( pixels[rowOff + col] & 0xff );
           try
              {
              encodePixelsWrapper( x, y + row, w, 1, rgbPixels, 0, w );
              }
           catch ( IOException e )
              {
              iox = e;
              stop();
              return;
              }
           }
       }

Here is the call graph for this function:

void Acme.JPM.Encoders.ImageEncoder.setPixels ( int  x,
int  y,
int  w,
int  h,
ColorModel  model,
int[]  pixels,
int  off,
int  scansize 
) [inline]

Definition at line 213 of file ImageEncoder.java.

       {
       if ( model == rgbModel )
           {
           try
              {
              encodePixelsWrapper( x, y, w, h, pixels, off, scansize );
              }
           catch ( IOException e )
              {
              iox = e;
              stop();
              return;
              }
           }
       else
           {
           int[] rgbPixels = new int[w];
            for ( int row = 0; row < h; ++row )
              {
              int rowOff = off + row * scansize;
                for ( int col = 0; col < w; ++col )
                    rgbPixels[col] = model.getRGB( pixels[rowOff + col] );
              try
                  {
                  encodePixelsWrapper( x, y + row, w, 1, rgbPixels, 0, w );
                  }
              catch ( IOException e )
                  {
                  iox = e;
                  stop();
                  return;
                  }
              }
           }
       }

Here is the call graph for this function:

void Acme.JPM.Encoders.ImageEncoder.setProperties ( Hashtable  props) [inline]

Definition at line 175 of file ImageEncoder.java.

       {
       this.props = props;
       }
synchronized void Acme.JPM.Encoders.ImageEncoder.stop ( ) [inline, private]

Definition at line 160 of file ImageEncoder.java.

       {
       encoding = false;
       notifyAll();
       }

Here is the caller graph for this function:


Member Data Documentation

boolean Acme.JPM.Encoders.ImageEncoder.accumulate = false [private]

Definition at line 123 of file ImageEncoder.java.

Definition at line 124 of file ImageEncoder.java.

Definition at line 65 of file ImageEncoder.java.

Reimplemented in Acme.JPM.Encoders.GifEncoder.

Definition at line 62 of file ImageEncoder.java.

Definition at line 63 of file ImageEncoder.java.

IOException Acme.JPM.Encoders.ImageEncoder.iox [private]

Definition at line 66 of file ImageEncoder.java.

OutputStream Acme.JPM.Encoders.ImageEncoder.out [protected]

Definition at line 58 of file ImageEncoder.java.

ImageProducer Acme.JPM.Encoders.ImageEncoder.producer [private]

Definition at line 60 of file ImageEncoder.java.

Hashtable Acme.JPM.Encoders.ImageEncoder.props = null [private]

Definition at line 68 of file ImageEncoder.java.

final ColorModel Acme.JPM.Encoders.ImageEncoder.rgbModel = ColorModel.getRGBdefault() [static, private]

Definition at line 67 of file ImageEncoder.java.

boolean Acme.JPM.Encoders.ImageEncoder.started = false [private]

Definition at line 64 of file ImageEncoder.java.

Reimplemented in Acme.JPM.Encoders.GifEncoder.

Definition at line 61 of file ImageEncoder.java.


The documentation for this class was generated from the following file: