Mercurial > hg > digilib-old
comparison servlet/src/digilib/image/JAIDocuImage.java @ 85:4e6757e8ccd4
New enhanced ImageLoader stuff.
Now uses Subsampling and image regions on read.
Now implements enhance, rotate and mirror for ImageLoader/Java2D
author | robcast |
---|---|
date | Thu, 27 Feb 2003 15:07:29 +0100 |
parents | 63c8186455c1 |
children | 997ba69afb81 |
comparison
equal
deleted
inserted
replaced
84:ed1b698b4f0a | 85:4e6757e8ccd4 |
---|---|
1 /* JAIDocuImage -- Image class implementation using JAI (Java Advanced Imaging) | 1 /* JAIDocuImage -- Image class implementation using JAI (Java Advanced Imaging) |
2 | 2 |
3 Digital Image Library servlet components | 3 Digital Image Library servlet components |
4 | 4 |
5 Copyright (C) 2001, 2002 Robert Casties (robcast@mail.berlios.de) | 5 Copyright (C) 2001, 2002, 2003 Robert Casties (robcast@mail.berlios.de) |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify it | 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 | 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 | 9 Free Software Foundation; either version 2 of the License, or (at your |
10 option) any later version. | 10 option) any later version. |
37 /** A DocuImage implementation using Java Advanced Imaging Library. */ | 37 /** A DocuImage implementation using Java Advanced Imaging Library. */ |
38 public class JAIDocuImage extends DocuImageImpl { | 38 public class JAIDocuImage extends DocuImageImpl { |
39 | 39 |
40 protected RenderedImage img; | 40 protected RenderedImage img; |
41 protected Interpolation interpol = null; | 41 protected Interpolation interpol = null; |
42 | |
43 // epsilon for float comparisons | |
44 public final double epsilon = 1e-5; | |
45 | 42 |
46 /** Default constructor. */ | 43 /** Default constructor. */ |
47 public JAIDocuImage() { | 44 public JAIDocuImage() { |
48 } | 45 } |
49 | 46 |
201 /* rotates the current image */ | 198 /* rotates the current image */ |
202 public void rotate(double angle) throws ImageOpException { | 199 public void rotate(double angle) throws ImageOpException { |
203 RenderedImage rotImg; | 200 RenderedImage rotImg; |
204 // convert degrees to radians | 201 // convert degrees to radians |
205 double rangle = Math.toRadians(angle); | 202 double rangle = Math.toRadians(angle); |
206 // rotate about the image center | 203 float x = getWidth()/2; |
207 double xoff = img.getWidth() / 2; | 204 float y = getHeight()/2; |
208 double yoff = img.getHeight() / 2; | |
209 | 205 |
210 // optimize rotation by right angles | 206 // optimize rotation by right angles |
211 TransposeType rotOp = null; | 207 TransposeType rotOp = null; |
212 if (Math.abs(angle - 0) < epsilon) { | 208 if (Math.abs(angle - 0) < epsilon) { |
213 // 0 degree | 209 // 0 degree |
233 rotImg = JAI.create("transpose", pb); | 229 rotImg = JAI.create("transpose", pb); |
234 } else { | 230 } else { |
235 // setup "normal" rotation | 231 // setup "normal" rotation |
236 ParameterBlock param = new ParameterBlock(); | 232 ParameterBlock param = new ParameterBlock(); |
237 param.addSource(img); | 233 param.addSource(img); |
238 param.add((float) xoff); | 234 param.add(x); |
239 param.add((float) yoff); | 235 param.add(y); |
240 param.add((float) rangle); | 236 param.add((float) rangle); |
241 param.add(interpol); | 237 param.add(interpol); |
242 // hint with border extender | 238 // hint with border extender |
243 RenderingHints hint = | 239 RenderingHints hint = |
244 new RenderingHints( | 240 new RenderingHints( |
249 } | 245 } |
250 | 246 |
251 util.dprintln( | 247 util.dprintln( |
252 3, | 248 3, |
253 "ROTATE: " | 249 "ROTATE: " |
254 + xoff | 250 + x |
255 + "," | 251 + "," |
256 + yoff | 252 + y |
257 + ", " | 253 + ", " |
258 + angle | 254 + angle |
259 + " (" | 255 + " (" |
260 + rangle | 256 + rangle |
261 + ")" | 257 + ")" |