comparison 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
comparison
equal deleted inserted replaced
72:300d5ba8b33b 73:3b8797fc3e90
18 18
19 */ 19 */
20 20
21 package digilib.image; 21 package digilib.image;
22 22
23 import javax.servlet.*; 23 import java.io.File;
24 import javax.servlet.http.*;
25 import java.io.*;
26 import java.util.*;
27 24
28 import java.awt.image.*; 25 import javax.servlet.ServletResponse;
29 import java.awt.image.renderable.*;
30 26
31 import digilib.*; 27 import digilib.io.FileOpException;
32 import digilib.io.*;
33 28
29
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 */
34 public interface DocuImage { 37 public interface DocuImage {
35 38
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 */
36 public String[] getKnownFileTypes(); 43 public String[] getKnownFileTypes();
37 44
38 /** 45 /** Loads an image file into the Object.
39 * send an image file as-is 46 *
40 */ 47 * @param f Image File.
41 public void sendFile(File f, ServletResponse res) throws FileOpException; 48 * @throws FileOpException Exception thrown if any error occurs.
42
43 /**
44 * load image file
45 */ 49 */
46 public void loadImage(File f) throws FileOpException; 50 public void loadImage(File f) throws FileOpException;
47 51
48 /** 52 /** Writes the current image to a ServletResponse.
49 * write image with mime type mt to Stream 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.
50 */ 62 */
51 public void writeImage(String mt, ServletResponse res) throws FileOpException; 63 public void writeImage(String mt, ServletResponse res) throws FileOpException;
52 64
53 /** 65 /** The width of the current image in pixel.
54 * get the image height and width 66 *
67 * @return Image width in pixels.
55 */ 68 */
56 public int getWidth(); 69 public int getWidth();
70
71 /** The height of the current image in pixel.
72 *
73 * @return Image height in pixels.
74 */
57 public int getHeight(); 75 public int getHeight();
58 76
59 /** 77 /** Crops and scales the current image.
60 * crop and scale image 78 *
61 * take rectangle width,height at position x_off,y_off 79 * The current image is cropped to a rectangle of <code>width</code>,
62 * and scale by scale with interpolation quality qual (0=worst) 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.
63 */ 91 */
64 public void cropAndScale( 92 public void cropAndScale(
65 int x_off, int y_off, 93 int x_off, int y_off,
66 int width, int height, 94 int width, int height,
67 float scale, int qual) throws ImageOpException; 95 float scale, int qual) throws ImageOpException;