Skip to content

Commit

Permalink
FOP-3163: Optimise performance of PNG with alpha using raw loader
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsteiner1984 committed Nov 29, 2023
1 parent 1cc4244 commit 23e173b
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -23,6 +23,7 @@

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;
Expand Down Expand Up @@ -117,7 +118,7 @@ public void setup(PDFDocument doc) {
// 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());
Expand Down Expand Up @@ -226,7 +227,7 @@ public void outputContents(OutputStream out) throws IOException {
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);
Expand Down

0 comments on commit 23e173b

Please sign in to comment.