From: Jeremias Maerki Date: Fri, 4 Jul 2003 18:53:40 +0000 (+0000) Subject: Bugfix for certain JPEG images that contain garbage after the EOI marker. X-Git-Tag: fop-0_20_5~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b5437fe2b32430cea7afea235b707aa121b6e964;p=xmlgraphics-fop.git Bugfix for certain JPEG images that contain garbage after the EOI marker. Adds error handling in case rendering an image fails in PS interpreter. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@196589 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/render/ps/PSRenderer.java b/src/org/apache/fop/render/ps/PSRenderer.java index 3381db157..38eaac8ae 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -624,6 +624,23 @@ public class PSRenderer extends AbstractRenderer { write(x + " " + (y - h) + " translate"); write(w + " " + h + " scale"); + + write("mark {{"); + // Template: (RawData is used for the EOF signal only) + // write("/RawData currentfile filter def"); + // write("/Data RawData [...] def"); + if (img instanceof JpegImage) { + write("/RawData currentfile /ASCII85Decode filter def"); + write("/Data RawData << >> /DCTDecode filter def"); + } else { + if (this.psLevel >= 3) { + write("/RawData currentfile /ASCII85Decode filter def"); + write("/Data RawData /FlateDecode filter def"); + } else { + write("/RawData currentfile /ASCII85Decode filter def"); + write("/Data RawData /RunLengthDecode filter def"); + } + } write("<<"); write(" /ImageType 1"); write(" /Width " + img.getWidth()); @@ -643,22 +660,17 @@ public class PSRenderer extends AbstractRenderer { write(" /ImageMatrix [" + img.getWidth() + " 0 0 -" + img.getHeight() + " 0 " + img.getHeight() + "]"); - if (img instanceof JpegImage) { - write(" /DataSource currentfile /ASCII85Decode filter /DCTDecode filter"); - } else { - if (this.psLevel >= 3) { - write(" /DataSource currentfile /ASCII85Decode filter /FlateDecode filter"); - } else { - write(" /DataSource currentfile /ASCII85Decode filter /RunLengthDecode filter"); - } - } - // write(" /DataSource currentfile /ASCIIHexDecode filter /FlateDecode filter"); - // write(" /DataSource currentfile /ASCIIHexDecode filter /RunLengthDecode filter"); - // write(" /DataSource currentfile /ASCIIHexDecode filter"); - // write(" /DataSource currentfile /ASCII85Decode filter"); - // write(" /DataSource currentfile /RunLengthDecode filter"); + write(" /DataSource Data"); write(">>"); write("image"); + /* the following two lines could be enabled if something still goes wrong + * write("Data closefile"); + * write("RawData flushfile"); + */ + write("} stopped {handleerror} if"); + write(" cleartomark"); + write(" RawData flushfile"); + write("} exec"); /* * for (int y=0; y= 3) { out = new FlateEncodeOutputStream(out); } else {