xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r410521 - in /xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl: PCLGenerator.java PCLGraphics2DAdapter.java PCLRenderer.java PCLRendererContext.java
Date Wed, 31 May 2006 13:36:18 GMT
Author: jeremias
Date: Wed May 31 06:36:18 2006
New Revision: 410521

URL: http://svn.apache.org/viewvc?rev=410521&view=rev
Log:
Fix for border painting in "quality" mode. Some borders were swallowed.
Added an additional parameter to distinguish between painting bitmap with source transparency
(bitmapped text and borders) and without (images).

Modified:
    xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGenerator.java
    xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
    xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java
    xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRendererContext.java

Modified: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGenerator.java?rev=410521&r1=410520&r2=410521&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGenerator.java (original)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGenerator.java Wed May
31 06:36:18 2006
@@ -578,9 +578,11 @@
      * (1-bit) bitmap image.
      * @param img the bitmap image
      * @param targetDim the target Dimention (in mpt)
+     * @param sourceTransparency true if the background should not be erased
      * @throws IOException In case of an I/O error
      */
-    public void paintBitmap(RenderedImage img, Dimension targetDim) throws IOException {
+    public void paintBitmap(RenderedImage img, Dimension targetDim, boolean sourceTransparency)

+                throws IOException {
         double targetResolution = img.getWidth() / UnitConv.mpt2in(targetDim.width);
         int resolution = (int)Math.round(targetResolution);
         int effResolution = calculatePCLResolution(resolution, true);
@@ -634,7 +636,7 @@
             
             RenderedImage red = buf;
             selectCurrentPattern(0, 0); //Solid black
-            setTransparencyMode(mask != null, true);
+            setTransparencyMode(sourceTransparency || mask != null, true);
             paintMonochromeBitmap(red, effResolution);
         } else {
             //TODO untested!
@@ -654,7 +656,7 @@
                 }
                 effImg = buf;
             }
-            setSourceTransparencyMode(false);
+            setSourceTransparencyMode(sourceTransparency);
             selectCurrentPattern(0, 0); //Solid black
             paintMonochromeBitmap(effImg, effResolution);
         }

Modified: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java?rev=410521&r1=410520&r2=410521&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
(original)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
Wed May 31 06:36:18 2006
@@ -112,7 +112,7 @@
             BufferedImage bi = paintToBufferedImage(painter, pclContext, resolution, true,
false);
 
             pcl.setCursorPos(x, y);
-            gen.paintBitmap(bi, new Dimension(width, height));
+            gen.paintBitmap(bi, new Dimension(width, height), pclContext.isSourceTransparency());
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java?rev=410521&r1=410520&r2=410521&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java Wed May 31
06:36:18 2006
@@ -101,6 +101,11 @@
     /** The MIME type for PCL */
     public static final String MIME_TYPE = MimeConstants.MIME_PCL_ALT;
 
+    private static final QName CONV_MODE 
+            = new QName(ExtensionElementMapping.URI, null, "conversion-mode");
+    private static final QName SRC_TRANSPARENCY 
+            = new QName(ExtensionElementMapping.URI, null, "source-transparency");
+    
     /** The OutputStream to write the PCL stream to */
     protected OutputStream out;
     
@@ -580,7 +585,8 @@
                 RendererContext rc = createRendererContext(paintRect.x, paintRect.y, 
                         paintRect.width, paintRect.height, null);
                 Map atts = new java.util.HashMap();
-                atts.put(new QName(ExtensionElementMapping.URI, null, "conversion-mode"),
"bitmap");
+                atts.put(CONV_MODE, "bitmap");
+                atts.put(SRC_TRANSPARENCY, "true");
                 rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
                 
                 Graphics2DImagePainter painter = new Graphics2DImagePainter() {
@@ -959,7 +965,9 @@
             try {
                 setCursorPos(this.currentIPPosition + (int)pos.getX(),
                         this.currentBPPosition + (int)pos.getY());
-                gen.paintBitmap(img, new Dimension((int)pos.getWidth(), (int)pos.getHeight()));
+                gen.paintBitmap(img, 
+                        new Dimension((int)pos.getWidth(), (int)pos.getHeight()), 
+                        false);
             } catch (IOException ioe) {
                 handleIOTrouble(ioe);
             }
@@ -1177,29 +1185,33 @@
         final Rectangle.Float effBorderRect = new Rectangle2D.Float(
                  borderRect.x - (currentIPPosition / 1000f),
                  borderRect.y - (currentBPPosition / 1000f),
-                 borderRect.width, borderRect.height);
+                 borderRect.width,
+                 borderRect.height);
         final Rectangle paintRect = new Rectangle(
-                (int)Math.round(borderRect.x * 1000),
-                (int)Math.round(borderRect.y * 1000), 
-                (int)Math.floor(borderRect.width * 1000) + 1,
-                (int)Math.floor(borderRect.height * 1000) + 1);
-        int xoffset = (bpsStart != null ? bpsStart.width : 0);
+                (int)Math.round(borderRect.x * 1000f),
+                (int)Math.round(borderRect.y * 1000f), 
+                (int)Math.floor(borderRect.width * 1000f) + 1,
+                (int)Math.floor(borderRect.height * 1000f) + 1);
+        //Add one pixel wide safety margin around the paint area
+        int pixelWidth = (int)Math.round(UnitConv.in2mpt(1) / userAgent.getTargetResolution());
+        final int xoffset = (bpsStart != null ? bpsStart.width : 0) + pixelWidth;
+        final int yoffset = pixelWidth;
         paintRect.x += xoffset;
-        paintRect.width += xoffset;
-        paintRect.width += (bpsEnd != null ? bpsEnd.width : 0);
+        paintRect.y += yoffset;
+        paintRect.width += 2 * pixelWidth;
+        paintRect.height += 2 * pixelWidth;
         
         RendererContext rc = createRendererContext(paintRect.x, paintRect.y, 
                 paintRect.width, paintRect.height, null);
-        if (false) {
-            Map atts = new java.util.HashMap();
-            atts.put(new QName(ExtensionElementMapping.URI, null, "conversion-mode"), "bitmap");
-            rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
-        }
+        Map atts = new java.util.HashMap();
+        atts.put(CONV_MODE, "bitmap");
+        atts.put(SRC_TRANSPARENCY, "true");
+        rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
         
         Graphics2DImagePainter painter = new Graphics2DImagePainter() {
 
             public void paint(Graphics2D g2d, Rectangle2D area) {
-                g2d.translate((bpsStart != null ? bpsStart.width : 0), 0);
+                g2d.translate(xoffset, yoffset);
                 g2d.scale(1000, 1000);
                 float startx = effBorderRect.x;
                 float starty = effBorderRect.y;

Modified: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRendererContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRendererContext.java?rev=410521&r1=410520&r2=410521&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRendererContext.java (original)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRendererContext.java Wed
May 31 06:36:18 2006
@@ -60,6 +60,12 @@
         return getForeignAttributes() != null 
              && "true".equalsIgnoreCase((String)getForeignAttributes().get(qName));
     }
+
+    public boolean isSourceTransparency() {
+        QName qName = new QName(ExtensionElementMapping.URI, null, "source-transparency");
+        return getForeignAttributes() != null 
+             && "true".equalsIgnoreCase((String)getForeignAttributes().get(qName));
+    }
     
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message