This is an automated email from the ASF dual-hosted git repository.

tilman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pdfbox-jbig2.git

commit d32c5d62db240017db96511950c58a7594b6f257
Author: Tilman Hausherr <[email protected]>
AuthorDate: Thu Apr 9 16:52:16 2026 +0200

    PDFBOX-5597: do Math.ceil() when subsampling
---
 src/main/java/org/apache/pdfbox/jbig2/image/Bitmaps.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/pdfbox/jbig2/image/Bitmaps.java 
b/src/main/java/org/apache/pdfbox/jbig2/image/Bitmaps.java
index 250315d..f87fe10 100644
--- a/src/main/java/org/apache/pdfbox/jbig2/image/Bitmaps.java
+++ b/src/main/java/org/apache/pdfbox/jbig2/image/Bitmaps.java
@@ -419,8 +419,8 @@ public class Bitmaps
         final int xSubsamplingOffset = param.getSubsamplingXOffset();
         final int ySubsamplingOffset = param.getSubsamplingYOffset();
 
-        final int dstWidth = (src.getWidth() - xSubsamplingOffset) / 
xSubsampling;
-        final int dstHeight = (src.getHeight() - ySubsamplingOffset) / 
ySubsampling;
+        final int dstWidth = (int) Math.ceil((src.getWidth() - 
xSubsamplingOffset) / (double) xSubsampling);
+        final int dstHeight = (int) Math.ceil((src.getHeight() - 
ySubsamplingOffset) / (double) ySubsampling);
 
         final Bitmap dst = new Bitmap(dstWidth, dstHeight);
 
@@ -445,7 +445,7 @@ public class Bitmaps
         if (src == null)
             throw new IllegalArgumentException("src must not be null");
 
-        final int dstHeight = (src.getWidth() - xSubsamplingOffset) / 
xSubsampling;
+        final int dstHeight = (int) Math.ceil((src.getWidth() - 
xSubsamplingOffset) / (double) xSubsampling);
         final Bitmap dst = new Bitmap(src.getWidth(), dstHeight);
 
         for (int yDst = 0; yDst < dst.getHeight(); yDst++)
@@ -468,7 +468,7 @@ public class Bitmaps
         if (src == null)
             throw new IllegalArgumentException("src must not be null");
 
-        final int dstWidth = (src.getWidth() - ySubsamplingOffset) / 
ySubsampling;
+        final int dstWidth = (int) Math.ceil((src.getWidth() - 
ySubsamplingOffset) / (double) ySubsampling);
         final Bitmap dst = new Bitmap(dstWidth, src.getHeight());
 
         for (int yDst = 0, ySrc = ySubsamplingOffset; yDst < dst

Reply via email to