]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-3163: Optimise performance of PNG with alpha using raw loader
authorSimon Steiner <ssteiner@apache.org>
Wed, 29 Nov 2023 16:17:22 +0000 (16:17 +0000)
committerSimon Steiner <ssteiner@apache.org>
Wed, 29 Nov 2023 16:17:22 +0000 (16:17 +0000)
fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java

index 9742036b79b9161d27b729a6e794a89af08ddccb..8a4258bfc28f6dd794ab66dcd090811a071d0b19 100644 (file)
@@ -23,6 +23,7 @@ package org.apache.fop.render.pdf;
 \r
 import java.awt.image.ColorModel;\r
 import java.awt.image.IndexColorModel;\r
+import java.io.BufferedOutputStream;\r
 import java.io.DataInputStream;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
@@ -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\r
             // and then deflate it back again\r
             ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-            DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater());\r
+            BufferedOutputStream dos = new BufferedOutputStream(new DeflaterOutputStream(baos, new Deflater()));\r
             InputStream in = ((ImageRawStream) image).createInputStream();\r
             try {\r
                 InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());\r
@@ -226,7 +227,7 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
                 int filter;\r
                 // here we need to inflate the PNG pixel data, which includes alpha, separate the alpha\r
                 // channel and then deflate the RGB channels back again\r
-                DeflaterOutputStream dos = new DeflaterOutputStream(out, new Deflater());\r
+                BufferedOutputStream dos = new BufferedOutputStream(new DeflaterOutputStream(out, new Deflater()));\r
                 while ((filter = dataStream.read()) != -1) {\r
                     byte[] bytes = new byte[bytesPerRow];\r
                     dataStream.readFully(bytes, 0, bytesPerRow);\r