pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1886174 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Date Wed, 03 Feb 2021 17:20:21 GMT
Author: tilman
Date: Wed Feb  3 17:20:20 2021
New Revision: 1886174

URL: http://svn.apache.org/viewvc?rev=1886174&view=rev
Log:
PDFBOX-5091: also consider subsampling when getting actual image to know its size

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1886174&r1=1886173&r2=1886174&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Wed Feb
 3 17:20:20 2021
@@ -987,8 +987,18 @@ public class PageDrawer extends PDFGraph
             // only when scaled up do we use nearest neighbour, eg PDFBOX-2302 / mori-cvpr01.pdf
             // PDFBOX-4930: we use the sizes of the ARGB image. These can be different
             // than the original sizes of the base image, when the mask is bigger.
-            boolean isScaledUp = pdImage.getImage().getWidth() < Math.round(at.getScaleX())
||
-                                 pdImage.getImage().getHeight() < Math.round(at.getScaleY());
+            // PDFBOX-5091: also consider subsampling, the sizes are different too.
+            BufferedImage bim;
+            if (subsamplingAllowed)
+            {
+                bim = pdImage.getImage(null, getSubsampling(pdImage, at));
+            }
+            else
+            {
+                bim = pdImage.getImage();
+            }
+            boolean isScaledUp = bim.getWidth() < Math.round(at.getScaleX()) ||
+                                 bim.getHeight() < Math.round(at.getScaleY());
 
             if (isScaledUp)
             {



Mime
View raw message