From: Jeremias Maerki Date: Mon, 12 Aug 2002 17:05:09 +0000 (+0000) Subject: Added a RunLengthEncode filter for the PostScript renderer. X-Git-Tag: fop-0_20_5rc~103 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f81324e61d2db71cfbe163b15ad6682901dd3143;p=xmlgraphics-fop.git Added a RunLengthEncode filter for the PostScript renderer. Submitted by: Stephen Wolke Added a property on the PostScript renderer for switching between PostScript Level 2 and 3. Default is Level 3. (Jeremias Maerki) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195082 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 746a424cc..d77689dce 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -118,6 +118,8 @@ public class PSRenderer extends AbstractRenderer { private FontInfo fontInfo; + private int psLevel = 3; + protected IDReferences idReferences; protected java.util.HashMap options; @@ -140,6 +142,29 @@ public class PSRenderer extends AbstractRenderer { this.options = options; } + + /** + * Sets the PostScript Level to generate. + * + * @param level You can specify either 2 or 3 for the PostScript Level + */ + public void setPSLevel(int level) { + switch (level) { + case 2: + case 3: + this.psLevel = level; + break; + default: + throw new IllegalArgumentException("Only PostScript Levels 2 and 3 are supported"); + } + } + + + public int getPSLevel() { + return this.psLevel; + } + + /** * write out a command */ @@ -539,12 +564,16 @@ public class PSRenderer extends AbstractRenderer { write(" /ImageMatrix [" + img.getWidth() + " 0 0 -" + img.getHeight() + " 0 " + img.getHeight() + "]"); - if (img instanceof JpegImage) + if (img instanceof JpegImage) { write(" /DataSource currentfile /ASCII85Decode filter /DCTDecode filter"); - else - write(" /DataSource currentfile /ASCII85Decode filter /FlateDecode 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 /ASCII85Decode filter /RunLengthDecode filter"); // write(" /DataSource currentfile /ASCIIHexDecode filter /RunLengthDecode filter"); // write(" /DataSource currentfile /ASCIIHexDecode filter"); // write(" /DataSource currentfile /ASCII85Decode filter"); @@ -572,7 +601,11 @@ public class PSRenderer extends AbstractRenderer { OutputStream out = this.out; out = new ASCII85OutputStream(out); if (!(img instanceof JpegImage)) { - out = new FlateEncodeOutputStream(out); + if (this.psLevel >= 3) { + out = new FlateEncodeOutputStream(out); + } else { + out = new RunLengthEncodeOutputStream(out); + } } out.write(imgmap); ((Finalizable)out).finalizeStream();