Author: jahewson
Date: Thu Apr  9 19:03:08 2015
New Revision: 1672455

URL: http://svn.apache.org/r1672455
Log:
PDFBOX-2753: Improve rendering of filled thin lines

Modified:
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1672455&r1=1672454&r2=1672455&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java 
(original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java 
Thu Apr  9 19:03:08 2015
@@ -36,7 +36,6 @@ import java.awt.image.Raster;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
@@ -529,8 +528,12 @@ public final class PageDrawer extends PD
 
         // disable anti-aliasing for rectangular paths, this is a workaround 
to avoid small stripes
         // which occur when solid fills are used to simulate piecewise 
gradients, see PDFBOX-2302
-        boolean isRectangular = isRectangular(linePath);
-        if (isRectangular)
+        // note that we ignore paths with a width/height under 1 as these are 
fills used as strokes,
+        // see PDFBOX-1658 for an example
+        Rectangle2D bounds = linePath.getBounds2D();
+        boolean noAntiAlias = isRectangular(linePath) && bounds.getWidth() > 1 
&&
+                                                         bounds.getHeight() > 
1;
+        if (noAntiAlias)
         {
             graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                       RenderingHints.VALUE_ANTIALIAS_OFF);
@@ -539,7 +542,7 @@ public final class PageDrawer extends PD
         graphics.fill(linePath);
         linePath.reset();
 
-        if (isRectangular)
+        if (noAntiAlias)
         {
             // JDK 1.7 has a bug where rendering hints are reset by the above 
call to
             // the setRenderingHint method, so we re-set all hints, see 
PDFBOX-2302


Reply via email to