01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.vfny.geoserver.wms.responses.map.gif;
06:
07: import org.geotools.image.ImageWorker;
08: import org.vfny.geoserver.global.WMS;
09: import org.vfny.geoserver.wms.WmsException;
10: import org.vfny.geoserver.wms.responses.DefaultRasterMapProducer;
11: import java.awt.image.RenderedImage;
12: import java.io.IOException;
13: import java.io.OutputStream;
14:
15: /**
16: * Handles a GetMap request that spects a map in GIF format.
17: *
18: * @author Didier Richard
19: * @author Simone Giannecchini - GeoSolutions
20: * @version $Id
21: */
22: public final class GIFMapProducer extends DefaultRasterMapProducer {
23:
24: public GIFMapProducer(String format, WMS wms) {
25: super (format, wms);
26: }
27:
28: /**
29: * Transforms the rendered image into the appropriate format, streaming to
30: * the output stream.
31: * @param image
32: * The image to be formatted.
33: * @param outStream
34: * The stream to write to.
35: *
36: * @throws WmsException
37: * not really.
38: * @throws IOException
39: * if encoding to <code>outStream</code> fails.
40: */
41: public void formatImageOutputStream(RenderedImage originalImage,
42: OutputStream outStream) throws WmsException, IOException {
43: // /////////////////////////////////////////////////////////////////
44: //
45: // Now the magic
46: //
47: // /////////////////////////////////////////////////////////////////
48: new ImageWorker(super .forceIndexed8Bitmask(originalImage))
49: .writeGIF(outStream, "LZW", 0.75f);
50: }
51:
52: public String getContentDisposition() {
53: // can be null
54: return null;
55: }
56:
57: }
|