01: /*
02: * $RCSfile: GZIPTileEncoder.java,v $
03: *
04: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
05: *
06: * Use is subject to license terms.
07: *
08: * $Revision: 1.1 $
09: * $Date: 2005/02/11 04:56:57 $
10: * $State: Exp $
11: */package com.sun.media.jai.tilecodec;
12:
13: import java.awt.image.Raster;
14: import java.io.IOException;
15: import java.io.OutputStream;
16: import java.io.ObjectOutputStream;
17: import java.util.zip.GZIPOutputStream;
18: import javax.media.jai.JAI;
19: import javax.media.jai.ParameterListDescriptor;
20: import javax.media.jai.tilecodec.TileEncoderImpl;
21: import javax.media.jai.tilecodec.TileCodecParameterList;
22:
23: /**
24: * A concrete implementation of the <code>TileEncoderImpl</code> class
25: * for the gzip tile codec.
26: */
27: public class GZIPTileEncoder extends TileEncoderImpl {
28:
29: /**
30: * Constructs an <code>GZIPTileEncoder</code>.
31: *
32: * @param output The <code>OutputStream</code> to write encoded data to.
33: * @param param The object containing the tile encoding parameters.
34: * @throws IllegalArgumentException if param is not the appropriate
35: * Class type.
36: * @throws IllegalArgumentException is output is null.
37: */
38: public GZIPTileEncoder(OutputStream output,
39: TileCodecParameterList param) {
40: super ("gzip", output, param);
41: }
42:
43: /**
44: * Encodes a <code>Raster</code> and writes the output
45: * to the <code>OutputStream</code> associated with this
46: * <code>TileEncoder</code>.
47: *
48: * @param ras the <code>Raster</code> to encode.
49: * @throws IOException if an I/O error occurs while writing to the
50: * OutputStream.
51: * @throws IllegalArgumentException if ras is null.
52: */
53: public void encode(Raster ras) throws IOException {
54: if (ras == null)
55: throw new IllegalArgumentException(JaiI18N
56: .getString("TileEncoder1"));
57:
58: ObjectOutputStream oos = new ObjectOutputStream(
59: new GZIPOutputStream(outputStream));
60: Object object = TileCodecUtils.serializeRaster(ras);
61: oos.writeObject(object);
62: oos.close();
63: }
64: }
|