01: /*
02: *
03: * Copyright (c) 2000 Silvere Martin-Michiellot All Rights Reserved.
04: *
05: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
06: * royalty free, license to use, modify and redistribute this
07: * software in source and binary code form,
08: * provided that i) this copyright notice and license appear on all copies of
09: * the software; and ii) Licensee does not utilize the software in a manner
10: * which is disparaging to Silvere Martin-Michiellot.
11: *
12: * This software is provided "AS IS," without a warranty of any kind. ALL
13: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
14: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
15: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
16: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
17: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
18: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
19: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
20: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
21: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
22: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
23: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
24: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
25: *
26: * This software is not designed or intended for use in on-line control of
27: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
28: * the design, construction, operation or maintenance of any nuclear
29: * facility. Licensee represents and warrants that it will not use or
30: * redistribute the Software for such purposes.
31: *
32: *
33: */
34:
35: package com.db.media.print;
36:
37: // This code is repackaged after the code from the Java3D SDK
38: // Site http://java.sun.com/
39: // Email java3d-interest@java.sun.com (mailing list)
40:
41: import java.awt.Graphics;
42: import java.awt.Image;
43: import java.awt.image.BufferedImage;
44: import java.awt.image.ImageObserver;
45: import java.io.FileOutputStream;
46: import java.io.IOException;
47:
48: //be sure before using this of using a JDK or JRE 1.2 from SUN
49: //other implementations may NOT have this class
50: import com.sun.image.codec.jpeg.*;
51:
52: public class ImageSaver implements ImageObserver {
53:
54: BufferedImage bImage;
55:
56: public ImageSaver(BufferedImage bImage) {
57:
58: this .bImage = bImage;
59:
60: }
61:
62: public void save(String url, float quality) {
63:
64: try {
65: FileOutputStream fileOutputStream = new FileOutputStream(
66: url);
67: JPEGImageEncoder encoder = JPEGCodec
68: .createJPEGEncoder(fileOutputStream);
69: JPEGEncodeParam param = encoder
70: .getDefaultJPEGEncodeParam(bImage);
71: param.setQuality(quality, false);
72: encoder.setJPEGEncodeParam(param);
73: encoder.encode(bImage);
74: fileOutputStream.close();
75: } catch (java.io.IOException e) {
76: System.out.println("I/O exception for image capture.");
77: }
78:
79: }
80:
81: public boolean imageUpdate(Image img, int infoflags, int x, int y,
82: int width, int height) {
83:
84: return false;
85:
86: }
87:
88: }
|