You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/10/12 07:21:35 UTC

svn commit: r1894146 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Author: tilman
Date: Tue Oct 12 07:21:34 2021
New Revision: 1894146

URL: http://svn.apache.org/viewvc?rev=1894146&view=rev
Log:
PDFBOX-5293: refactor by removing adjustRectangle(); update TODO comment

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1894146&r1=1894145&r2=1894146&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Tue Oct 12 07:21:34 2021
@@ -697,23 +697,9 @@ public class PageDrawer extends PDFGraph
         }
         gray = adjustImage(gray);
         Rectangle2D tpgBounds = transparencyGroup.getBounds();
-        adjustRectangle(tpgBounds);
         return new SoftMask(parentPaint, gray, tpgBounds, backdropColor, softMask.getTransferFunction());
     }
 
-    // this adjusts the rectangle to the rotated image to put the soft mask at the correct position
-    //TODO after all transparency problems have been solved:
-    // 1. shouldn't this be done in transparencyGroup.getBounds() ?
-    // 2. change transparencyGroup.getBounds() to getOrigin(), because size isn't used in SoftMask
-    // 3. Is it possible to create the softmask and transparency group in the correct rotation?
-    //    (needs rendering identity testing before committing!)
-    private void adjustRectangle(Rectangle2D r)
-    {
-        AffineTransform adjustedTransform = new AffineTransform(xform);
-        adjustedTransform.scale(1.0 / xformScalingFactorX, 1.0 / xformScalingFactorY);
-        r.setRect(adjustedTransform.createTransformedShape(r).getBounds2D());
-    }
-
     // returns the image adjusted for applySoftMaskToPaint().
     private BufferedImage adjustImage(BufferedImage gray)
     {
@@ -1880,9 +1866,22 @@ public class PageDrawer extends PDFGraph
         public Rectangle2D getBounds()
         {
             // apply the underlying Graphics2D device's DPI transform and y-axis flip
-            return new Rectangle2D.Double(minX - pageSize.getLowerLeftX() * xformScalingFactorX,
-                    (pageSize.getLowerLeftY() + pageSize.getHeight()) * xformScalingFactorY - minY - height,
-                    width, height);
+            Rectangle2D r =
+                    new Rectangle2D.Double(
+                            minX - pageSize.getLowerLeftX() * xformScalingFactorX,
+                            (pageSize.getLowerLeftY() + pageSize.getHeight()) * xformScalingFactorY - minY - height,
+                            width,
+                            height);
+            // this adjusts the rectangle to the rotated image to put the soft mask at the correct position
+            //TODO
+            // 1. change transparencyGroup.getBounds() to getOrigin(), because size isn't used in SoftMask;
+            //    also remove use of AffineTransform here
+            // 2. Is it possible to create the softmask and transparency group in the correct rotation?
+            //    (needs rendering identity testing before committing!)
+            AffineTransform adjustedTransform = new AffineTransform(xform);
+            adjustedTransform.scale(1.0 / xformScalingFactorX, 1.0 / xformScalingFactorY);
+            r.setRect(adjustedTransform.createTransformedShape(r).getBounds2D());
+            return r;
         }
     }