]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added a RunLengthEncode filter for the PostScript renderer.
authorJeremias Maerki <jeremias@apache.org>
Mon, 12 Aug 2002 17:05:09 +0000 (17:05 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 12 Aug 2002 17:05:09 +0000 (17:05 +0000)
Submitted by: Stephen Wolke <smwolke@geistig.com>

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

src/org/apache/fop/render/ps/PSRenderer.java

index 746a424cc947a98c66be13c6b602af2977912647..d77689dce8c733016478bc312dbff2f191aca70d 100644 (file)
@@ -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();