public abstract class ImageEncoder
extends java.lang.Object
implements java.awt.image.ImageConsumer
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.
Copyright (C)1996,1998 by Jef Poskanzer (jef@acme.com). All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit the ACME Labs Java page for up-to-date versions of this and other fine Java utilities: http://www.acme.com/java/
GifEncoder,
PpmEncoder| Constructor and Description |
|---|
ImageEncoder(java.awt.Image img,
java.io.OutputStream out)
Constructor.
|
ImageEncoder(java.awt.image.ImageProducer producer,
java.io.OutputStream out)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
encode()
Call this after initialization to get things going.
|
java.util.Hashtable |
getProperties() |
void |
imageComplete(int status) |
void |
setColorModel(java.awt.image.ColorModel model) |
void |
setDimensions(int width,
int height) |
void |
setHints(int hintflags) |
void |
setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel model,
byte[] pixels,
int off,
int scansize) |
void |
setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel model,
int[] pixels,
int off,
int scansize) |
void |
setProperties(java.util.Hashtable props) |
public ImageEncoder(java.awt.Image img,
java.io.OutputStream out)
img - The image to encode.out - The stream to write the bytes to.public ImageEncoder(java.awt.image.ImageProducer producer,
java.io.OutputStream out)
producer - The ImageProducer to encode.out - The stream to write the bytes to.public void encode()
throws java.io.IOException
java.io.IOExceptionpublic void setDimensions(int width,
int height)
setDimensions in interface java.awt.image.ImageConsumerpublic void setProperties(java.util.Hashtable props)
setProperties in interface java.awt.image.ImageConsumerpublic java.util.Hashtable getProperties()
public void setColorModel(java.awt.image.ColorModel model)
setColorModel in interface java.awt.image.ImageConsumerpublic void setHints(int hintflags)
setHints in interface java.awt.image.ImageConsumerpublic void setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel model,
byte[] pixels,
int off,
int scansize)
setPixels in interface java.awt.image.ImageConsumerpublic void setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel model,
int[] pixels,
int off,
int scansize)
setPixels in interface java.awt.image.ImageConsumerpublic void imageComplete(int status)
imageComplete in interface java.awt.image.ImageConsumer"