aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2023-11-29 16:17:22 +0000
committerSimon Steiner <ssteiner@apache.org>2023-11-29 16:17:22 +0000
commit23e173b7e6e095c15ac2384e462abbc4281f3e32 (patch)
tree263c752bc953b20967281e7b4f44a7a1d45e2eca
parent1cc4244b69d8de060e8fb00e86d4f2a9871e503d (diff)
downloadxmlgraphics-fop-23e173b7e6e095c15ac2384e462abbc4281f3e32.tar.gz
xmlgraphics-fop-23e173b7e6e095c15ac2384e462abbc4281f3e32.zip
FOP-3163: Optimise performance of PNG with alpha using raw loader
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java b/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
index 9742036b7..8a4258bfc 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
@@ -23,6 +23,7 @@ package org.apache.fop.render.pdf;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
+import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -117,7 +118,7 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
// here we need to inflate the PNG pixel data, which includes alpha, separate the alpha channel
// and then deflate it back again
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater());
+ BufferedOutputStream dos = new BufferedOutputStream(new DeflaterOutputStream(baos, new Deflater()));
InputStream in = ((ImageRawStream) image).createInputStream();
try {
InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
@@ -226,7 +227,7 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
int filter;
// here we need to inflate the PNG pixel data, which includes alpha, separate the alpha
// channel and then deflate the RGB channels back again
- DeflaterOutputStream dos = new DeflaterOutputStream(out, new Deflater());
+ BufferedOutputStream dos = new BufferedOutputStream(new DeflaterOutputStream(out, new Deflater()));
while ((filter = dataStream.read()) != -1) {
byte[] bytes = new byte[bytesPerRow];
dataStream.readFully(bytes, 0, bytesPerRow);