# HG changeset patch # User robcast # Date 1061331861 -7200 # Node ID d76006c12e892f842b0ca91d3702991cf328b9ee # Parent d87a7e2515af065b3ab896f53ae48c59f28feeae corrected bugs with Java2D on Linux... diff -r d87a7e2515af -r d76006c12e89 servlet/src/digilib/image/ImageLoaderDocuImage.java --- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Aug 19 22:31:48 2003 +0200 +++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Wed Aug 20 00:24:21 2003 +0200 @@ -222,9 +222,7 @@ BufferedImage scaledImg = null; // enforce grey destination image for greyscale *Java2D BUG* if ((quality > 0) - && ((img.getType() == BufferedImage.TYPE_BYTE_GRAY) - || (img.getType() == BufferedImage.TYPE_BYTE_BINARY) - || (img.getType() == BufferedImage.TYPE_USHORT_GRAY))) { + && (img.getColorModel().getNumColorComponents() == 1)) { Rectangle2D dstBounds = scaleOp.getBounds2D(img); scaledImg = new BufferedImage( @@ -250,7 +248,6 @@ } public void blur(int radius) throws ImageOpException { - BufferedImage blurredImg; //DEBUG util.dprintln(4, "blur: " + radius); // minimum radius is 2 @@ -265,7 +262,16 @@ Kernel blur = new Kernel(klen, klen, kern); // blur with convolve operation ConvolveOp blurOp = new ConvolveOp(blur, ConvolveOp.EDGE_NO_OP, null); - blurredImg = blurOp.filter(img, null); + // blur needs explicit destination image type for color *Java2D BUG* + BufferedImage blurredImg = null; + if (img.getType() == BufferedImage.TYPE_3BYTE_BGR) { + blurredImg = + new BufferedImage( + img.getWidth(), + img.getHeight(), + img.getType()); + } + blurredImg = blurOp.filter(img, blurredImg); if (blurredImg == null) { util.dprintln(2, "ERROR(cropAndScale): error in scale"); throw new ImageOpException("Unable to scale"); @@ -291,15 +297,15 @@ public void enhance(float mult, float add) throws ImageOpException { /* Only one constant should work regardless of the number of bands - * according to the JDK spec. - * Doesn't work on JDK 1.4 for OSX and Linux (at least). - */ /* RescaleOp scaleOp = - new RescaleOp( - (float)mult, (float)add, - null); - scaleOp.filter(img, img); - */ /* The number of constants must match the number of bands in the image. - */ + * according to the JDK spec. + * Doesn't work on JDK 1.4 for OSX and Linux (at least). + */ /* RescaleOp scaleOp = + new RescaleOp( + (float)mult, (float)add, + null); + scaleOp.filter(img, img); + */ /* The number of constants must match the number of bands in the image. + */ int ncol = img.getColorModel().getNumColorComponents(); float[] dm = new float[ncol]; float[] da = new float[ncol]; @@ -313,8 +319,8 @@ public void enhanceRGB(float[] rgbm, float[] rgba) throws ImageOpException { /* The number of constants must match the number of bands in the image. - * We do only 3 (RGB) bands. - */ + * We do only 3 (RGB) bands. + */ int ncol = img.getColorModel().getNumColorComponents(); if ((ncol != 3) || (rgbm.length != 3) || (rgba.length != 3)) { util.dprintln( @@ -328,7 +334,7 @@ new RescaleOp(rgbOrdered(rgbm), rgbOrdered(rgba), null); scaleOp.filter(img, img); } /** Ensures that the array f is in the right order to map the images RGB components. - */ + */ public float[] rgbOrdered(float[] fa) { float[] fb = new float[3]; int t = img.getType(); diff -r d87a7e2515af -r d76006c12e89 servlet/src/digilib/servlet/Scaler.java --- a/servlet/src/digilib/servlet/Scaler.java Tue Aug 19 22:31:48 2003 +0200 +++ b/servlet/src/digilib/servlet/Scaler.java Wed Aug 20 00:24:21 2003 +0200 @@ -58,7 +58,7 @@ public class Scaler extends HttpServlet { // digilib servlet version (for all components) - public static final String dlVersion = "1.12b5"; + public static final String dlVersion = "1.12b6"; // Utils instance with debuglevel Utils util;