changeset 145:d76006c12e89

corrected bugs with Java2D on Linux...
author robcast
date Wed, 20 Aug 2003 00:24:21 +0200
parents d87a7e2515af
children acfcafefe5b7
files servlet/src/digilib/image/ImageLoaderDocuImage.java servlet/src/digilib/servlet/Scaler.java
diffstat 2 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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();
--- 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;