6696292: Printing transformed images accuracy problems
authorprr
Tue, 13 May 2008 16:49:21 -0700
changeset 553 38a9503f374d
parent 551 6a51745b2784
child 554 88eb2812c2a4
6696292: Printing transformed images accuracy problems Reviewed-by: jgodinez, igor
jdk/src/share/classes/sun/print/PSPathGraphics.java
jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java
--- a/jdk/src/share/classes/sun/print/PSPathGraphics.java	Tue May 13 16:18:30 2008 -0700
+++ b/jdk/src/share/classes/sun/print/PSPathGraphics.java	Tue May 13 16:49:21 2008 -0700
@@ -344,8 +344,15 @@
         double devScaleX = devResX / DEFAULT_USER_RES;
         double devScaleY = devResY / DEFAULT_USER_RES;
 
-        if (scaleX > devScaleX) scaleX = devScaleX;
-        if (scaleY > devScaleY) scaleY = devScaleY;
+        /* check if rotated or sheared */
+        int transformType = fullTransform.getType();
+        boolean clampScale = ((transformType &
+                               (AffineTransform.TYPE_GENERAL_ROTATION |
+                                AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0);
+        if (clampScale) {
+            if (scaleX > devScaleX) scaleX = devScaleX;
+            if (scaleY > devScaleY) scaleY = devScaleY;
+        }
 
         /* We do not need to draw anything if either scaling
          * factor is zero.
--- a/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java	Tue May 13 16:18:30 2008 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java	Tue May 13 16:49:21 2008 -0700
@@ -943,8 +943,16 @@
         double devResY = wPrinterJob.getYRes();
         double devScaleX = devResX / DEFAULT_USER_RES;
         double devScaleY = devResY / DEFAULT_USER_RES;
-        if (scaleX > devScaleX) scaleX = devScaleX;
-        if (scaleY > devScaleY) scaleY = devScaleY;
+
+        /* check if rotated or sheared */
+        int transformType = fullTransform.getType();
+        boolean clampScale = ((transformType &
+                               (AffineTransform.TYPE_GENERAL_ROTATION |
+                                AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0);
+        if (clampScale) {
+            if (scaleX > devScaleX) scaleX = devScaleX;
+            if (scaleY > devScaleY) scaleY = devScaleY;
+        }
 
         /* We do not need to draw anything if either scaling
          * factor is zero.