Mercurial > hg > digilib-old
comparison servlet/src/digilib/image/DocuImage.java @ 79:63c8186455c1
Servlet version 1.6b. Further cleanup and new functionality:
* mirroring
* contrast/brightness
* rotation (not finished)
author | robcast |
---|---|
date | Mon, 03 Feb 2003 16:04:53 +0100 |
parents | 3b8797fc3e90 |
children | 4e6757e8ccd4 |
comparison
equal
deleted
inserted
replaced
78:e0dcac9c66fa | 79:63c8186455c1 |
---|---|
19 */ | 19 */ |
20 | 20 |
21 package digilib.image; | 21 package digilib.image; |
22 | 22 |
23 import java.io.File; | 23 import java.io.File; |
24 | 24 import java.io.OutputStream; |
25 import javax.servlet.ServletResponse; | |
26 | 25 |
27 import digilib.io.FileOpException; | 26 import digilib.io.FileOpException; |
28 | |
29 | 27 |
30 /** The basic class for the representation of a digilib image. | 28 /** The basic class for the representation of a digilib image. |
31 * | 29 * |
32 * The actual image object is hidden in the class, only methods for loading, | 30 * The actual image object is hidden in the class, only methods for loading, |
33 * manipulation, and saving are exported. This strategy enables implementations | 31 * manipulation, and saving are exported. This strategy enables implementations |
34 * using different toolkits that rely on different image base classes (like | 32 * using different toolkits that rely on different image base classes (like |
35 * JIMI, Java2D and JAI). | 33 * JIMI, Java2D and JAI). |
36 */ | 34 */ |
37 public interface DocuImage { | 35 public interface DocuImage { |
38 | 36 |
39 /** Returns the list of image file types known to the DocuImage implementation. | 37 /** Returns the list of image file types known to the DocuImage implementation. |
40 * | 38 * |
41 * @return List of image file types. Strings are standard file extensions. | 39 * @return List of image file types. Strings are standard file extensions. |
42 */ | 40 */ |
43 public String[] getKnownFileTypes(); | 41 public String[] getKnownFileTypes(); |
44 | 42 |
45 /** Loads an image file into the Object. | 43 /** Loads an image file into the Object. |
46 * | 44 * |
47 * @param f Image File. | 45 * @param f Image File. |
48 * @throws FileOpException Exception thrown if any error occurs. | 46 * @throws FileOpException Exception thrown if any error occurs. |
49 */ | 47 */ |
50 public void loadImage(File f) throws FileOpException; | 48 public void loadImage(File f) throws FileOpException; |
51 | 49 |
52 /** Writes the current image to a ServletResponse. | 50 /** Writes the current image to a ServletResponse. |
53 * | 51 * |
54 * The image is encoded to the mime-type <code>mt</code> and sent to the output | 52 * 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>. | 53 * stream of the <code>ServletResponse</code> <code>res</code>. |
56 * | 54 * |
57 * Currently only mime-types "image/jpeg" and "image/png" are supported. | 55 * Currently only mime-types "image/jpeg" and "image/png" are supported. |
58 * | 56 * |
59 * @param mt mime-type of the image to be sent. | 57 * @param mt mime-type of the image to be sent. |
60 * @param res ServletResponse where the image is sent. | 58 * @param res ServletResponse where the image is sent. |
61 * @throws FileOpException Exception thrown on any error. | 59 * @throws FileOpException Exception thrown on any error. |
62 */ | 60 */ |
63 public void writeImage(String mt, ServletResponse res) throws FileOpException; | 61 public void writeImage(String mt, OutputStream ostream) |
62 throws FileOpException; | |
64 | 63 |
65 /** The width of the current image in pixel. | 64 /** The width of the current image in pixel. |
66 * | 65 * |
67 * @return Image width in pixels. | 66 * @return Image width in pixels. |
68 */ | 67 */ |
69 public int getWidth(); | 68 public int getWidth(); |
70 | |
71 /** The height of the current image in pixel. | |
72 * | |
73 * @return Image height in pixels. | |
74 */ | |
75 public int getHeight(); | |
76 | 69 |
77 /** Crops and scales the current image. | 70 /** The height of the current image in pixel. |
78 * | 71 * |
79 * The current image is cropped to a rectangle of <code>width</code>, | 72 * @return Image height in pixels. |
80 * <code>height</code> at position <code>x_off</code>, <code>y_off</code>. The | 73 */ |
81 * resulting image is scaled by the factor <code>scale</code> using the | 74 public int getHeight(); |
82 * interpolation quality <code>qual</code> (0=worst). | 75 |
83 * | 76 /** Crops the current image. |
84 * @param x_off x offset of the crop rectangle in pixel. | 77 * |
85 * @param y_off y offset of the crop rectangle in pixel. | 78 * Cuts out a region of the size <code>width</code> x <code>height</code> at |
86 * @param width width of the crop rectangle in pixel. | 79 * the offset <code>xoff</code>, <code>yoff</code> from the current image |
87 * @param height height of the crop rectangle in pixel. | 80 * and replaces the current image with the result. |
88 * @param scale scaling factor. | 81 * |
89 * @param qual interpolation quality (0=worst). | 82 * @param xoff X offset of crop region |
90 * @throws ImageOpException exception thrown on any error. | 83 * @param yoff Y offset of crop region |
91 */ | 84 * @param width width of crop region |
92 public void cropAndScale( | 85 * @param height height of crop region |
93 int x_off, int y_off, | 86 * @throws ImageOpException |
94 int width, int height, | 87 */ |
95 float scale, int qual) throws ImageOpException; | 88 public void crop(int xoff, int yoff, int width, int height) |
89 throws ImageOpException; | |
90 | |
91 /** Scales the current image. | |
92 * | |
93 * Replaces the current image with an image scaled by the factor | |
94 * <code>scale</code>. | |
95 * | |
96 * @param scale scaling factor | |
97 * @throws ImageOpException | |
98 */ | |
99 public void scale(double scale) throws ImageOpException; | |
100 | |
101 /** Crops and scales the current image. | |
102 * | |
103 * The current image is cropped to a rectangle of <code>width</code>, | |
104 * <code>height</code> at position <code>x_off</code>, <code>y_off</code>. The | |
105 * resulting image is scaled by the factor <code>scale</code> using the | |
106 * interpolation quality <code>qual</code> (0=worst). | |
107 * | |
108 * @param x_off x offset of the crop rectangle in pixel. | |
109 * @param y_off y offset of the crop rectangle in pixel. | |
110 * @param width width of the crop rectangle in pixel. | |
111 * @param height height of the crop rectangle in pixel. | |
112 * @param scale scaling factor. | |
113 * @param qual interpolation quality (0=worst). | |
114 * @throws ImageOpException exception thrown on any error. | |
115 */ | |
116 public void cropAndScale( | |
117 int x_off, | |
118 int y_off, | |
119 int width, | |
120 int height, | |
121 double scale, | |
122 int qual) | |
123 throws ImageOpException; | |
124 | |
125 /** Rotates the current image. | |
126 * | |
127 * Replaces the current image with a rotated image. The image is rotated | |
128 * around the center by <code>angle</code> given in degrees [0, 360] | |
129 * clockwise. Image size and aspect ratio are likely to change. | |
130 * | |
131 * @param angle rotation angle in degree | |
132 */ | |
133 public void rotate(double angle) throws ImageOpException; | |
134 | |
135 /** Mirrors the current image. | |
136 * | |
137 * Replaces the current image with a mirrored image. The mirror axis goes | |
138 * through the center of the image and is rotated by <code>angle</code> | |
139 * degrees. Currently only horizontal and vertical mirroring (0 and 90 | |
140 * degree) are supported. | |
141 * | |
142 * @param angle angle of mirror axis | |
143 * @throws ImageOpException | |
144 */ | |
145 public void mirror(double angle) throws ImageOpException; | |
146 | |
147 /** Enhaces brightness and contrast of the current image. | |
148 * | |
149 * Replaces the current image with a brightness and contrast enhanced image. | |
150 * Contrast is enhanced by multiplying the pixel value with the constant | |
151 * <code>mult</code>. Brightness is enhanced by adding the constant | |
152 * <code>add</code> to the pixel value. Operation: p1 = (p0*mult)+add. | |
153 * | |
154 * @param mult multiplicative constant for contrast enhancement | |
155 * @param add additive constant for brightness enhancement | |
156 * @throws ImageOpException | |
157 */ | |
158 public void enhance(double mult, double add) throws ImageOpException; | |
159 | |
160 /** | |
161 * Returns the interpolation quality. | |
162 * @return int | |
163 */ | |
164 public int getQuality(); | |
165 | |
166 /** | |
167 * Sets the interpolation quality. | |
168 * @param quality The quality to set | |
169 */ | |
170 public void setQuality(int quality); | |
171 | |
96 } | 172 } |