Author: tilman
Date: Mon Jun 15 18:08:36 2026
New Revision: 1935372
Log:
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #475
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
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Mon Jun 15 18:08:33 2026 (r1935371)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Mon Jun 15 18:08:36 2026 (r1935372)
@@ -1281,7 +1281,9 @@ public class PageDrawer extends PDFGraph
// calculate subsampling according to the resulting image size
double scale = Math.abs(at.getDeterminant() * xform.getDeterminant());
- int subsampling = (int) Math.floor(Math.sqrt(pdImage.getWidth() *
pdImage.getHeight() / scale));
+ int imageWidth = pdImage.getWidth();
+ int imageHeight = pdImage.getHeight();
+ int subsampling = (int) Math.floor(Math.sqrt(imageWidth * imageHeight
/ scale));
if (subsampling > 8)
{
subsampling = 8;
@@ -1290,11 +1292,11 @@ public class PageDrawer extends PDFGraph
{
subsampling = 1;
}
- if (subsampling > pdImage.getWidth() || subsampling >
pdImage.getHeight())
+ if (subsampling > imageWidth || subsampling > imageHeight)
{
// For very small images it is possible that the subsampling would
imply 0 size.
// To avoid problems, the subsampling is set to no less than the
smallest dimension.
- subsampling = Math.min(pdImage.getWidth(), pdImage.getHeight());
+ subsampling = Math.min(imageWidth, imageHeight);
}
return subsampling;
}