annotate servlet/src/digilib/image/DocuImage.java @ 73:3b8797fc3e90

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