pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1644572 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/BeginInlineImage.java
Date Thu, 11 Dec 2014 07:41:04 GMT
Author: tilman
Date: Thu Dec 11 07:41:04 2014
New Revision: 1644572

URL: http://svn.apache.org/r1644572
Log:
PDFBOX-2552: normalize the rotation angle for all values

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/BeginInlineImage.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/BeginInlineImage.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/BeginInlineImage.java?rev=1644572&r1=1644571&r2=1644572&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/BeginInlineImage.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/BeginInlineImage.java
Thu Dec 11 07:41:04 2014
@@ -78,7 +78,16 @@ public class BeginInlineImage extends Op
         double pageHeight = drawer.getPageSize().getHeight();
         
         Matrix ctm = drawer.getGraphicsState().getCurrentTransformationMatrix();
-        int pageRotation = page.findRotation();
+        int rotationAngle = page.findRotation();
+        // normalize the rotation angle
+        while (rotationAngle < 0)
+        {
+            rotationAngle += 360;
+        }
+        while (rotationAngle >= 360)
+        {
+            rotationAngle -= 360;
+        }        
 
         AffineTransform ctmAT = ctm.createAffineTransform();
         ctmAT.scale(1f/imageWidth, 1f/imageHeight);
@@ -90,11 +99,11 @@ public class BeginInlineImage extends Op
         // tan = sin/cos
         double angle = Math.atan(ctmAT.getShearX()/ctmAT.getScaleX());
         Matrix translationMatrix = null;
-        if (pageRotation == 0 || pageRotation == 180) 
+        if (rotationAngle == 0 || rotationAngle == 180) 
         {
             translationMatrix = Matrix.getTranslatingInstance((float)(Math.sin(angle)*ctm.getXScale()),
(float)(pageHeight-2*ctm.getYPosition()-Math.cos(angle)*ctm.getYScale())); 
         }
-        else if (pageRotation == 90 || pageRotation == 270) 
+        else if (rotationAngle == 90 || rotationAngle == 270) 
         {
             translationMatrix = Matrix.getTranslatingInstance((float)(Math.sin(angle)*ctm.getYScale()),
(float)(pageHeight-2*ctm.getYPosition())); 
         }



Mime
View raw message