Class ImageEncoder
- java.lang.Object
-
- jv.thirdParty.acmeEncoders.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.ImageConsumerAbstract 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.
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/
- See Also:
GifEncoder,PpmEncoder- Version:
- 11.05.05, 2.10 revised (ep) Color model bug handling extended to work with j2sdk1.5
06.11.00, 2.00 revised (ep) Win NT color model bug handling.
-
-
Constructor Summary
Constructors Constructor and Description ImageEncoder(java.awt.Image img, java.io.OutputStream out)Constructor.ImageEncoder(java.awt.image.ImageProducer producer, java.io.OutputStream out)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidencode()Call this after initialization to get things going.java.util.HashtablegetProperties()voidimageComplete(int status)voidsetColorModel(java.awt.image.ColorModel model)voidsetDimensions(int width, int height)voidsetHints(int hintflags)voidsetPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, byte[] pixels, int off, int scansize)voidsetPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, int[] pixels, int off, int scansize)voidsetProperties(java.util.Hashtable props)
-
-
-
Constructor Detail
-
ImageEncoder
public ImageEncoder(java.awt.Image img, java.io.OutputStream out)Constructor.- Parameters:
img- The image to encode.out- The stream to write the bytes to.- Version:
- 06.11.00, 2.00 revised (ep) Also stores the image (for Win NT color model bug handling)
-
ImageEncoder
public ImageEncoder(java.awt.image.ImageProducer producer, java.io.OutputStream out)Constructor.- Parameters:
producer- The ImageProducer to encode.out- The stream to write the bytes to.
-
-
Method Detail
-
encode
public void encode() throws java.io.IOExceptionCall this after initialization to get things going. This method tries to analyse the color model which is necessary on different computer systems. Otherwise wrong colors may appear.- Throws:
java.io.IOException- Version:
- 10.06.02, 3.10 revised (kp) Catch exception which is thrown on with Sun Jdk but not with MS-Java
when exporting an image while display is in antialias mode.
14.12.00, 3.00 revised (ep) 06.11.00, 2.00 revised (ep) Adapted for Win NT color model bug.
-
setDimensions
public void setDimensions(int width, int height)- Specified by:
setDimensionsin interfacejava.awt.image.ImageConsumer
-
setProperties
public void setProperties(java.util.Hashtable props)
- Specified by:
setPropertiesin interfacejava.awt.image.ImageConsumer
-
getProperties
public java.util.Hashtable getProperties()
-
setColorModel
public void setColorModel(java.awt.image.ColorModel model)
- Specified by:
setColorModelin interfacejava.awt.image.ImageConsumer
-
setHints
public void setHints(int hintflags)
- Specified by:
setHintsin interfacejava.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)- Specified by:
setPixelsin interfacejava.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)- Specified by:
setPixelsin interfacejava.awt.image.ImageConsumer- Version:
- 06.11.00, 2.00 revised (ep) Adapted for Win NT color model bug.
-
imageComplete
public void imageComplete(int status)
- Specified by:
imageCompletein interfacejava.awt.image.ImageConsumer
-
-
"