1
|
1 /* DocuImage -- General image interface class
|
|
2
|
|
3 Digital Image Library servlet components
|
|
4
|
531
|
5 Copyright (C) 2001, 2002, 2003 Robert Casties (robcast@mail.berlios.de)
|
1
|
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
|
531
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1
|
18
|
|
19 */
|
|
20
|
|
21 package digilib.image;
|
|
22
|
531
|
23 import java.awt.Rectangle;
|
|
24 import java.io.IOException;
|
|
25 import java.io.OutputStream;
|
|
26 import java.util.Iterator;
|
|
27
|
|
28 import digilib.io.ImageFile;
|
|
29 import digilib.io.FileOpException;
|
1
|
30
|
531
|
31 /** The basic class for the representation of a digilib image.
|
|
32 *
|
|
33 * The actual image object is hidden in the class, only methods for loading,
|
|
34 * manipulation, and saving are exported. This strategy enables implementations
|
|
35 * using different toolkits that rely on different image base classes (like
|
|
36 * JIMI, Java2D and JAI).
|
|
37 */
|
1
|
38 public interface DocuImage {
|
|
39
|
531
|
40 /** Loads an image file into the Object.
|
|
41 *
|
|
42 * @param f Image File.
|
|
43 * @throws FileOpException Exception thrown if any error occurs.
|
|
44 */
|
|
45 public void loadImage(ImageFile f) throws FileOpException;
|
|
46
|
|
47 /** This DocuImage support the loadSubImage operation.
|
|
48 *
|
|
49 * @return boolean
|
|
50 */
|
|
51 public boolean isSubimageSupported();
|
1
|
52
|
531
|
53 /** Load only a subsampled region of the image file.
|
|
54 *
|
|
55 * @param f
|
|
56 * @param region
|
|
57 * @param subsample
|
|
58 * @throws FileOpException
|
|
59 */
|
|
60 public void loadSubimage(ImageFile f, Rectangle region, int subsample)
|
|
61 throws FileOpException;
|
|
62
|
|
63 /** Writes the current image to a ServletResponse.
|
|
64 *
|
|
65 * The image is encoded to the mime-type <code>mt</code> and sent to the output
|
|
66 * stream of the <code>ServletResponse</code> <code>res</code>.
|
|
67 *
|
|
68 * Currently only mime-types "image/jpeg" and "image/png" are supported.
|
|
69 *
|
|
70 * @param mt mime-type of the image to be sent.
|
|
71 * @param res ServletResponse where the image is sent.
|
|
72 * @throws FileOpException Exception thrown on any error.
|
|
73 */
|
|
74 public void writeImage(String mt, OutputStream ostream)
|
|
75 throws FileOpException;
|
1
|
76
|
531
|
77 /** The width of the current image in pixel.
|
|
78 *
|
|
79 * @return Image width in pixels.
|
|
80 */
|
|
81 public int getWidth();
|
|
82
|
|
83 /** The height of the current image in pixel.
|
|
84 *
|
|
85 * @return Image height in pixels.
|
|
86 */
|
|
87 public int getHeight();
|
|
88
|
|
89 /** The mime-type of the current image.
|
|
90 *
|
|
91 * @return String the mime-type of this image.
|
|
92 */
|
|
93 public String getMimetype();
|
1
|
94
|
531
|
95 /** Crops the current image.
|
|
96 *
|
|
97 * Cuts out a region of the size <code>width</code> x <code>height</code> at
|
|
98 * the offset <code>xoff</code>, <code>yoff</code> from the current image
|
|
99 * and replaces the current image with the result.
|
|
100 *
|
|
101 * @param xoff X offset of crop region
|
|
102 * @param yoff Y offset of crop region
|
|
103 * @param width width of crop region
|
|
104 * @param height height of crop region
|
|
105 * @throws ImageOpException
|
|
106 */
|
|
107 public void crop(int xoff, int yoff, int width, int height)
|
|
108 throws ImageOpException;
|
|
109
|
|
110 /** Scales the current image.
|
|
111 *
|
|
112 * Replaces the current image with an image scaled by the factor
|
|
113 * <code>scale</code>.
|
|
114 *
|
|
115 * @param scale scaling factor
|
|
116 * @throws ImageOpException
|
|
117 */
|
|
118 public void scale(double scaleX, double scaleY) throws ImageOpException;
|
1
|
119
|
531
|
120 /** Crops and scales the current image.
|
|
121 *
|
|
122 * The current image is cropped to a rectangle of <code>width</code>,
|
|
123 * <code>height</code> at position <code>x_off</code>, <code>y_off</code>. The
|
|
124 * resulting image is scaled by the factor <code>scale</code> using the
|
|
125 * interpolation quality <code>qual</code> (0=worst).
|
|
126 *
|
|
127 * @param x_off x offset of the crop rectangle in pixel.
|
|
128 * @param y_off y offset of the crop rectangle in pixel.
|
|
129 * @param width width of the crop rectangle in pixel.
|
|
130 * @param height height of the crop rectangle in pixel.
|
|
131 * @param scale scaling factor.
|
|
132 * @param qual interpolation quality (0=worst).
|
|
133 * @throws ImageOpException exception thrown on any error.
|
|
134 */
|
|
135 public void cropAndScale(
|
|
136 int x_off,
|
|
137 int y_off,
|
|
138 int width,
|
|
139 int height,
|
|
140 double scale,
|
|
141 int qual)
|
|
142 throws ImageOpException;
|
|
143
|
|
144 /** Rotates the current image.
|
|
145 *
|
|
146 * Replaces the current image with a rotated image. The image is rotated
|
|
147 * around the center by the <code>angle</code>
|
|
148 * given in degrees [0, 360] clockwise.
|
|
149 * Image size and aspect ratio are likely to change.
|
|
150 *
|
|
151 * @param angle rotation angle in degree
|
|
152 */
|
|
153 public void rotate(double angle) throws ImageOpException;
|
|
154
|
|
155 /** Mirrors the current image.
|
|
156 *
|
|
157 * Replaces the current image with a mirrored image. The mirror axis goes
|
|
158 * through the center of the image and is rotated by <code>angle</code>
|
|
159 * degrees. Currently only horizontal and vertical mirroring (0 and 90
|
|
160 * degree) are supported.
|
|
161 *
|
|
162 * @param angle angle of mirror axis
|
|
163 * @throws ImageOpException
|
|
164 */
|
|
165 public void mirror(double angle) throws ImageOpException;
|
1
|
166
|
531
|
167 /** Enhances brightness and contrast of the current image.
|
|
168 *
|
|
169 * Replaces the current image with a brightness and contrast enhanced image.
|
|
170 * Contrast is enhanced by multiplying the pixel value with the constant
|
|
171 * <code>mult</code>. Brightness is enhanced by adding the constant
|
|
172 * <code>add</code> to the pixel value. Operation: p1 = (p0*mult)+add.
|
|
173 *
|
|
174 * @param mult multiplicative constant for contrast enhancement
|
|
175 * @param add additive constant for brightness enhancement
|
|
176 * @throws ImageOpException
|
|
177 */
|
|
178 public void enhance(float mult, float add) throws ImageOpException;
|
|
179
|
|
180 /** Manipulates the colors of the current image.
|
|
181 *
|
|
182 * Replaces the current image with a color modified image.
|
|
183 * For the red, green and blue color channels all pixel values are multiplied
|
|
184 * by the constant
|
|
185 * <code>m</code> and added to the constant
|
|
186 * <code>a</code>. Operation: p1 = (p0*m)+a.
|
|
187 *
|
|
188 * @param rgbm multiplicative constants for red, green, blue
|
|
189 * @param rgba additive constant for red, green, blue
|
|
190 * @throws ImageOpException
|
|
191 */
|
|
192 public void enhanceRGB(float[] rgbm, float[] rgba)
|
|
193 throws ImageOpException;
|
|
194
|
|
195 /**
|
|
196 * Returns the interpolation quality.
|
|
197 * @return int
|
|
198 */
|
|
199 public int getQuality();
|
|
200
|
|
201 /**
|
|
202 * Sets the interpolation quality.
|
|
203 * @param quality The quality to set
|
|
204 */
|
|
205 public void setQuality(int quality);
|
|
206
|
|
207 /** Frees all resources bound to the DocuImage.
|
|
208 *
|
|
209 * Things that should be freed are image objects and open files.
|
|
210 *
|
|
211 */
|
|
212 public void dispose();
|
|
213
|
|
214 /**
|
|
215 * Check image size and type and store in ImageFile f
|
|
216 */
|
|
217 public boolean identify(ImageFile imgf) throws IOException;
|
|
218
|
|
219 /**
|
|
220 * Returns a list of supported image formats
|
|
221 */
|
|
222 public Iterator<String> getSupportedFormats();
|
|
223
|
1
|
224 }
|