sorry I forgot the attachment

here it comes

> Hey!
>
> Based on the PNG Transcoder I wrote a GIF Transcoder. It uses the GIF
> Encoder provided by acme
> http://www.acme.com/java/software/Acme.JPM.Encoders.GifEncoder.html.
> This Encoder doesn't support transparency. I knew a freely available
> Encoder which supports transparency, but I can't find it anymore. In case
> you don't want the dependency with the acme lib, I would suggest that you
> comment out the compilation of the GIFTranscoder by default in the
> build.xml file.
>
>
> Roland Schulz
/*****************************************************************************
 * Copyright (C) The Apache Software Foundation. All rights reserved.        *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Apache Software License *
 * version 1.1, a copy of which has been included with this distribution in  *
 * the LICENSE file.                                                         *
 *****************************************************************************/

package net.sourceforge.xweb.backend.images;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.batik.transcoder.*;
import org.apache.batik.transcoder.image.ImageTranscoder;
import org.apache.batik.transcoder.image.resources.Messages;
import Acme.JPM.Encoders.*;
//import com.eteks.filter.Web216ColorsFilter;

/**
 * This class is an <tt>ImageTranscoder</tt> that produces a GIF image.
 *
 * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
 * @version $Id: GIFTranscoder.java,v 1.5 2001/09/10 13:54:35 rschulz Exp $
 */
public class GIFTranscoder extends ImageTranscoder {

    /**
     * Constructs a new transcoder that produces gif images.
     */
    public GIFTranscoder() {
        hints.put(ImageTranscoder.KEY_BACKGROUND_COLOR, Color.white);
    }

    /**
     * Creates a new ARGB image with the specified dimension.
     * @param width the image width in pixels
     * @param height the image height in pixels
     */
    public BufferedImage createImage(int width, int height) {
        return new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    }

    /**
     * Writes the specified image to the specified output.
     * @param img the image to write
     * @param output the output where to store the image
     * @param TranscoderException if an error occured while storing the image
     */
    public void writeImage(BufferedImage img, TranscoderOutput output)
            throws TranscoderException {
        OutputStream ostream = output.getOutputStream();
        if (ostream == null) {
            throw new TranscoderException(
                Messages.formatMessage("gif.badoutput", null));
        }
        try {
	    /*NoCM is the pja (www.eteks.com/pja/en) version from the original acme Version
	      (www.acme.com/java/software/). It has been modified by the pja people to avoid
	      loading of the java.awt.image.ColorModel class. But you can't use it for free for 
	      comercial use! The only advantage of pja is, not needing a X Server to use the (modified) AWT.

	      Another modified version of the original acme version can be found at
	      jmge.net/java/gifenc/. But is more complex and because I don't need animation
	      I haven't tested it much.
	    */
	    /*new GifEncoderNoCM (new FilteredImageSource (img.getSource (),
					       new Web216ColorsFilter ()),
				ostream).encode ();
	    */
	    new GifEncoder (img, ostream).encode ();
	    //new net.jmge.gif.Gif89Encoder(img).encode(ostream);
        } catch (IOException ex) {
            throw new TranscoderException(ex);
        }
    }

}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to