# HG changeset patch # User robcast # Date 1052771624 -7200 # Node ID 0e49645f98c87b0327fed4632e3cd6312db73150 # Parent 5fdf109d31c253aa02f544d8e4d55b218ff1720c Servlet V1.9b2 Fixes error in rotation for ImageLoader DocuImage. diff -r 5fdf109d31c2 -r 0e49645f98c8 servlet/src/digilib/image/ImageLoaderDocuImage.java --- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Mon May 05 22:30:50 2003 +0200 +++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Mon May 12 22:33:44 2003 +0200 @@ -286,32 +286,37 @@ // create offset to make shure the rotated image has no negative coordinates double w = img.getWidth(); double h = img.getHeight(); - double xoff = (w / 2) * Math.sin(rangle); - double yoff = (h / 2) * Math.sin(rangle); - double off = Math.max(xoff, yoff)+10; - // move image - AffineTransform trafo = AffineTransform.getTranslateInstance(off, off); - // new center of rotation - double x = (w / 2) + off; - double y = (h / 2) + off; + AffineTransform trafo = new AffineTransform(); + // center of rotation + double x = (w / 2); + double y = (h / 2); trafo.rotate(rangle, x, y); + // try rotation to see how far we're out of bounds + AffineTransformOp rotOp = new AffineTransformOp(trafo, interpol); + Rectangle2D rotbounds = rotOp.getBounds2D(img); + double xoff = rotbounds.getX(); + double yoff = rotbounds.getY(); + // move image back in line + trafo.preConcatenate(AffineTransform.getTranslateInstance(-xoff, -yoff)); // transform image - AffineTransformOp rotOp = new AffineTransformOp(trafo, interpol); + rotOp = new AffineTransformOp(trafo, interpol); BufferedImage rotImg = rotOp.filter(img, null); // calculate new bounding box - Rectangle2D bounds = rotOp.getBounds2D(img); + //Rectangle2D bounds = rotOp.getBounds2D(img); if (rotImg == null) { util.dprintln(2, "ERROR: error in rotate"); throw new ImageOpException("Unable to rotate"); } + img = rotImg; // crop new image (with self-made rounding) - img = + /* img = rotImg.getSubimage( (int) (bounds.getX()+0.5), (int) (bounds.getY()+0.5), (int) (bounds.getWidth()+0.5), (int) (bounds.getHeight()+0.5)); + */ } public void mirror(double angle) throws ImageOpException { diff -r 5fdf109d31c2 -r 0e49645f98c8 servlet/src/digilib/servlet/Scaler.java --- a/servlet/src/digilib/servlet/Scaler.java Mon May 05 22:30:50 2003 +0200 +++ b/servlet/src/digilib/servlet/Scaler.java Mon May 12 22:33:44 2003 +0200 @@ -56,7 +56,7 @@ public class Scaler extends HttpServlet { // digilib servlet version (for all components) - public static final String dlVersion = "1.9b1"; + public static final String dlVersion = "1.9b2"; // Utils instance with debuglevel Utils util;