aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/render')
-rw-r--r--src/java/org/apache/fop/render/bitmap/PNGRenderer.java9
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRenderer.java52
-rw-r--r--src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java23
-rw-r--r--src/java/org/apache/fop/render/ps/ImageEncoderPNG.java16
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java8
7 files changed, 64 insertions, 48 deletions
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
index 6f45d18ca..623b28618 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
@@ -118,11 +118,12 @@ public class PNGRenderer extends Java2DRenderer {
= BitmapRendererEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
eventProducer.noImageWriterFound(this, getMimeType());
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Writing image using " + writer.getClass().getName());
+ }
+ writer.writeImage(image, os, params);
}
- if (log.isDebugEnabled()) {
- log.debug("Writing image using " + writer.getClass().getName());
- }
- writer.writeImage(image, os, params);
}
/**
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
index 619d0625e..442660c3b 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
@@ -117,35 +117,35 @@ public class TIFFRenderer extends Java2DRenderer {
= BitmapRendererEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
eventProducer.noImageWriterFound(this, getMimeType());
- }
- if (writer.supportsMultiImageWriter()) {
- MultiImageWriter multiWriter = writer.createMultiImageWriter(outputStream);
- try {
- // Write all pages/images
- while (pageImagesItr.hasNext()) {
- RenderedImage img = (RenderedImage) pageImagesItr.next();
- multiWriter.writeImage(img, imageSettings.getWriterParams());
- }
- } finally {
- multiWriter.close();
- }
} else {
- RenderedImage renderedImage = null;
- if (pageImagesItr.hasNext()) {
- renderedImage = (RenderedImage) pageImagesItr.next();
- }
- writer.writeImage(renderedImage, outputStream, imageSettings.getWriterParams());
- if (pageImagesItr.hasNext()) {
- BitmapRendererEventProducer eventProducer
- = BitmapRendererEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.stoppingAfterFirstPageNoFilename(this);
+ if (writer.supportsMultiImageWriter()) {
+ MultiImageWriter multiWriter = writer.createMultiImageWriter(outputStream);
+ try {
+ // Write all pages/images
+ while (pageImagesItr.hasNext()) {
+ RenderedImage img = (RenderedImage) pageImagesItr.next();
+ multiWriter.writeImage(img, imageSettings.getWriterParams());
+ }
+ } finally {
+ multiWriter.close();
+ }
+ } else {
+ RenderedImage renderedImage = null;
+ if (pageImagesItr.hasNext()) {
+ renderedImage = (RenderedImage) pageImagesItr.next();
+ }
+ writer.writeImage(renderedImage, outputStream, imageSettings.getWriterParams());
+ if (pageImagesItr.hasNext()) {
+ BitmapRendererEventProducer eventProducer
+ = BitmapRendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.stoppingAfterFirstPageNoFilename(this);
+ }
}
+ // Cleaning
+ outputStream.flush();
+ clearViewportList();
}
-
- // Cleaning
- outputStream.flush();
- clearViewportList();
log.debug("TIFF encoding done.");
}
diff --git a/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
index 5f69fbadb..f40ca6d94 100644
--- a/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
@@ -119,13 +119,15 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
ByteArrayOutputStream baos = null;
DeflaterOutputStream dos = null;
InputStream in = null;
+ InflaterInputStream infStream = null;
+ DataInputStream dataStream = null;
try {
baos = new ByteArrayOutputStream();
dos = new DeflaterOutputStream(baos, new Deflater());
in = ((ImageRawStream) image).createInputStream();
try {
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ infStream = new InflaterInputStream(in, new Inflater());
+ dataStream = new DataInputStream(infStream);
// offset is the byte offset of the alpha component
int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA
int numColumns = image.getSize().getWidthPx();
@@ -159,12 +161,13 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
}
BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),
image.getSize().getHeightPx(), baos.toByteArray(), null);
- IOUtils.closeQuietly(baos);
alphaMask.setPDFFilter(transFlate);
alphaMask.disallowMultipleFilters();
alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
softMask = doc.addImage(null, alphaMask).makeReference();
} finally {
+ IOUtils.closeQuietly(infStream);
+ IOUtils.closeQuietly(dataStream);
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(dos);
IOUtils.closeQuietly(baos);
@@ -216,7 +219,9 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
/** {@inheritDoc} */
public void outputContents(OutputStream out) throws IOException {
InputStream in = ((ImageRawStream) image).createInputStream();
-
+ InflaterInputStream infStream = null;
+ DataInputStream dataStream = null;
+ DeflaterOutputStream dos = null;
try {
if (numberOfInterleavedComponents == 1 || numberOfInterleavedComponents == 3) {
// means we have Gray, RGB, or Palette
@@ -226,14 +231,14 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
// TODO: since we have alpha here do this when the alpha channel is extracted
int numBytes = numberOfInterleavedComponents - 1; // 1 for Gray, 3 for RGB
int numColumns = image.getSize().getWidthPx();
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ infStream = new InflaterInputStream(in, new Inflater());
+ dataStream = new DataInputStream(infStream);
int offset = 0;
int bytesPerRow = numberOfInterleavedComponents * numColumns;
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());
+ dos = new DeflaterOutputStream(out, new Deflater());
while ((filter = dataStream.read()) != -1) {
byte[] bytes = new byte[bytesPerRow];
dataStream.readFully(bytes, 0, bytesPerRow);
@@ -244,9 +249,11 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
}
offset = 0;
}
- dos.close();
}
} finally {
+ IOUtils.closeQuietly(dos);
+ IOUtils.closeQuietly(dataStream);
+ IOUtils.closeQuietly(infStream);
IOUtils.closeQuietly(in);
}
}
diff --git a/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java b/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java
index 5746a3fbe..8ab91cb0a 100644
--- a/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java
+++ b/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java
@@ -65,6 +65,10 @@ public class ImageEncoderPNG implements ImageEncoder {
public void writeTo(OutputStream out) throws IOException {
// TODO: refactor this code with equivalent PDF code
InputStream in = ((ImageRawStream) image).createInputStream();
+ InflaterInputStream infStream = null;
+ DataInputStream dataStream = null;
+ ByteArrayOutputStream baos = null;
+ DeflaterOutputStream dos = null;
try {
if (numberOfInterleavedComponents == 1 || numberOfInterleavedComponents == 3) {
// means we have Gray, RGB, or Palette
@@ -73,8 +77,8 @@ public class ImageEncoderPNG implements ImageEncoder {
// means we have Gray + alpha or RGB + alpha
int numBytes = numberOfInterleavedComponents - 1; // 1 for Gray, 3 for RGB
int numColumns = image.getSize().getWidthPx();
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ infStream = new InflaterInputStream(in, new Inflater());
+ dataStream = new DataInputStream(infStream);
int offset = 0;
int bytesPerRow = numberOfInterleavedComponents * numColumns;
int filter;
@@ -83,8 +87,8 @@ public class ImageEncoderPNG implements ImageEncoder {
// TODO: not using the baos below and using the original out instead (as happens in PDF)
// would be preferable but that does not work with the rest of the postscript code; this
// needs to be revisited
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DeflaterOutputStream dos = new DeflaterOutputStream(/* out */baos, new Deflater());
+ baos = new ByteArrayOutputStream();
+ dos = new DeflaterOutputStream(/* out */baos, new Deflater());
while ((filter = dataStream.read()) != -1) {
byte[] bytes = new byte[bytesPerRow];
dataStream.readFully(bytes, 0, bytesPerRow);
@@ -99,6 +103,10 @@ public class ImageEncoderPNG implements ImageEncoder {
IOUtils.copy(new ByteArrayInputStream(baos.toByteArray()), out);
}
} finally {
+ IOUtils.closeQuietly(dos);
+ IOUtils.closeQuietly(baos);
+ IOUtils.closeQuietly(dataStream);
+ IOUtils.closeQuietly(infStream);
IOUtils.closeQuietly(in);
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
index 5013e0958..8dd58739c 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
@@ -168,7 +168,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
}
//check for keep-together
- if (attrib != null && attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) {
+ if (attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) {
writeControlWord(ROW_KEEP_TOGETHER);
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
index 0ee70bf31..fb590ab63 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
@@ -58,7 +58,7 @@ public final class ImageUtil {
* number The digits as integer
*/
public static int getInt(String value) {
- String retString = new String();
+ String retString = "";
StringBuffer s = new StringBuffer(value);
int len = s.length();
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
index 85f1261f7..3e1aca1c1 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
@@ -168,9 +168,9 @@ public class TableContext implements ITableColumnsInfo {
while (colIndex >= colFirstSpanningCol.size()) {
setNextFirstSpanningCol(false);
}
- colFirstSpanningCol.set(colIndex, new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.set(colIndex, Boolean.valueOf(bFirstSpanningCol));
} else {
- colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.add(Boolean.valueOf(bFirstSpanningCol));
}
}
@@ -181,7 +181,7 @@ public class TableContext implements ITableColumnsInfo {
*/
public void setNextFirstSpanningCol(
boolean bFirstSpanningCol) {
- colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.add(Boolean.valueOf(bFirstSpanningCol));
}
/**
@@ -202,7 +202,7 @@ public class TableContext implements ITableColumnsInfo {
if (i.intValue() == 0) {
colRowSpanningAttrs.set(z, null);
- colFirstSpanningCol.set(z, new Boolean(false));
+ colFirstSpanningCol.set(z, Boolean.valueOf(false));
}
}
}