1
|
1 /* DocuImage -- General image interface class
|
|
2
|
|
3 Digital Image Library servlet components
|
|
4
|
|
5 Copyright (C) 2001, 2002 Robert Casties (robcast@mail.berlios.de)
|
|
6
|
|
7 This program is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2 of the License, or (at your
|
|
10 option) any later version.
|
|
11
|
|
12 Please read license.txt for the full details. A copy of the GPL
|
|
13 may be found at http://www.gnu.org/copyleft/lgpl.html
|
|
14
|
|
15 You should have received a copy of the GNU General Public License
|
|
16 along with this program; if not, write to the Free Software
|
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
|
19 */
|
|
20
|
|
21 package digilib.image;
|
|
22
|
73
|
23 import java.io.File;
|
|
24
|
|
25 import javax.servlet.ServletResponse;
|
|
26
|
|
27 import digilib.io.FileOpException;
|
|
28
|
1
|
29
|
73
|
30 /** The basic class for the representation of a digilib image.
|
|
31 *
|
|
32 * The actual image object is hidden in the class, only methods for loading,
|
|
33 * manipulation, and saving are exported. This strategy enables implementations
|
|
34 * using different toolkits that rely on different image base classes (like
|
|
35 * JIMI, Java2D and JAI).
|
|
36 */
|
1
|
37 public interface DocuImage {
|
|
38
|
73
|
39 /** Returns the list of image file types known to the DocuImage implementation.
|
|
40 *
|
|
41 * @return List of image file types. Strings are standard file extensions.
|
|
42 */
|
1
|
43 public String[] getKnownFileTypes();
|
|
44
|
73
|
45 /** Loads an image file into the Object.
|
|
46 *
|
|
47 * @param f Image File.
|
|
48 * @throws FileOpException Exception thrown if any error occurs.
|
1
|
49 */
|
|
50 public void loadImage(File f) throws FileOpException;
|
|
51
|
73
|
52 /** Writes the current image to a ServletResponse.
|
|
53 *
|
|
54 * The image is encoded to the mime-type <code>mt</code> and sent to the output
|
|
55 * stream of the <code>ServletResponse</code> <code>res</code>.
|
|
56 *
|
|
57 * Currently only mime-types "image/jpeg" and "image/png" are supported.
|
|
58 *
|
|
59 * @param mt mime-type of the image to be sent.
|
|
60 * @param res ServletResponse where the image is sent.
|
|
61 * @throws FileOpException Exception thrown on any error.
|
1
|
62 */
|
|
63 public void writeImage(String mt, ServletResponse res) throws FileOpException;
|
|
64
|
73
|
65 /** The width of the current image in pixel.
|
|
66 *
|
|
67 * @return Image width in pixels.
|
1
|
68 */
|
|
69 public int getWidth();
|
73
|
70
|
|
71 /** The height of the current image in pixel.
|
|
72 *
|
|
73 * @return Image height in pixels.
|
|
74 */
|
1
|
75 public int getHeight();
|
|
76
|
73
|
77 /** Crops and scales the current image.
|
|
78 *
|
|
79 * The current image is cropped to a rectangle of <code>width</code>,
|
|
80 * <code>height</code> at position <code>x_off</code>, <code>y_off</code>. The
|
|
81 * resulting image is scaled by the factor <code>scale</code> using the
|
|
82 * interpolation quality <code>qual</code> (0=worst).
|
|
83 *
|
|
84 * @param x_off x offset of the crop rectangle in pixel.
|
|
85 * @param y_off y offset of the crop rectangle in pixel.
|
|
86 * @param width width of the crop rectangle in pixel.
|
|
87 * @param height height of the crop rectangle in pixel.
|
|
88 * @param scale scaling factor.
|
|
89 * @param qual interpolation quality (0=worst).
|
|
90 * @throws ImageOpException exception thrown on any error.
|
1
|
91 */
|
|
92 public void cropAndScale(
|
|
93 int x_off, int y_off,
|
|
94 int width, int height,
|
|
95 float scale, int qual) throws ImageOpException;
|
|
96 }
|