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 2019/07/20 13:59:20 UTC
[pdfbox-jbig2] branch master updated: PDFBOX-4598: reduce memory
footprint by creating packed raster for 1 bit images,
as suggested by Hee Jeong Kim
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
The following commit(s) were added to refs/heads/master by this push:
new 506f388 PDFBOX-4598: reduce memory footprint by creating packed raster for 1 bit images, as suggested by Hee Jeong Kim
506f388 is described below
commit 506f388db72d8b2c7916cc9002af59bd20a7d58e
Author: Tilman Hausherr <ti...@snafu.de>
AuthorDate: Sat Jul 20 15:32:40 2019 +0200
PDFBOX-4598: reduce memory footprint by creating packed raster for 1 bit images, as suggested by Hee Jeong Kim
---
src/main/java/org/apache/pdfbox/jbig2/image/Bitmaps.java | 12 ++++++++----
1 file changed, 8 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 895741f..255ea22 100644
--- a/src/main/java/org/apache/pdfbox/jbig2/image/Bitmaps.java
+++ b/src/main/java/org/apache/pdfbox/jbig2/image/Bitmaps.java
@@ -174,11 +174,13 @@ public class Bitmaps
(int) Math.round(bitmap.getWidth() * scaleX), //
(int) Math.round(bitmap.getHeight() * scaleY));
- final WritableRaster dst = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
- dstBounds.width, dstBounds.height, 1, new Point());
+ WritableRaster dst;
if (scaleX != 1 || scaleY != 1)
{
+ dst = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
+ dstBounds.width, dstBounds.height, 1, new Point());
+
// scaling required
final Resizer resizer = new Resizer(scaleX, scaleY);
final Filter filter = Filter.byType(filterType);
@@ -187,6 +189,9 @@ public class Bitmaps
}
else
{
+ dst = WritableRaster.createPackedRaster(DataBuffer.TYPE_BYTE,
+ dstBounds.width, dstBounds.height, 1, 1, new Point());
+
// scaling not required, paste bitmap into raster pixel per pixel
int byteIndex = 0;
for (int y = 0; y < bitmap.getHeight(); y++)
@@ -287,8 +292,7 @@ public class Bitmaps
}
else
{
-
- cm = new IndexColorModel(8, 2, //
+ cm = new IndexColorModel(1, 2, //
new byte[] { 0x00, (byte) 0xff }, new byte[] { 0x00, (byte) 0xff },
new byte[] { 0x00, (byte) 0xff });
}