pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1563639 - in /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics: pattern/ shading/
Date Sun, 02 Feb 2014 15:38:41 GMT
Author: lehmi
Date: Sun Feb  2 15:38:41 2014
New Revision: 1563639

URL: http://svn.apache.org/r1563639
Log:
PDFBOX-615: added support for type 4 and type 5 shading patterns as proposed by Tilman Hausherr

Added:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java
      - copied, changed from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudTriangle.java
      - copied unchanged from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudTriangle.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingContext.java
      - copied unchanged from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingContext.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java
      - copied, changed from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingContext.java
      - copied unchanged from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingContext.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java
      - copied, changed from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java
      - copied, changed from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java
Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java?rev=1563639&r1=1563638&r2=1563639&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java
Sun Feb  2 15:38:41 2014
@@ -35,14 +35,17 @@ import org.apache.pdfbox.pdmodel.graphic
 import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType1;
 import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType2;
 import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType3;
+import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType4;
+import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType5;
 import org.apache.pdfbox.pdmodel.graphics.shading.RadialShadingPaint;
 import org.apache.pdfbox.pdmodel.graphics.shading.Type1ShadingPaint;
+import org.apache.pdfbox.pdmodel.graphics.shading.Type4ShadingPaint;
+import org.apache.pdfbox.pdmodel.graphics.shading.Type5ShadingPaint;
 import org.apache.pdfbox.util.Matrix;
 
 /**
  * This represents the resources for a shading pattern.
  *
- * @version $Revision: 1.0 $
  */
 public class PDShadingPatternResources extends PDPatternResources
 {
@@ -217,7 +220,11 @@ public class PDShadingPatternResources e
                 paint = new RadialShadingPaint((PDShadingType3)getShading(), getMatrix(),
pageHeight);
                 break;
             case PDShadingResources.SHADING_TYPE4:
+                paint = new Type4ShadingPaint((PDShadingType4)getShading(), getMatrix(),
pageHeight);
+                break;
             case PDShadingResources.SHADING_TYPE5:
+                paint = new Type5ShadingPaint((PDShadingType5)getShading(), getMatrix(),
pageHeight);
+                break;
             case PDShadingResources.SHADING_TYPE6:
             case PDShadingResources.SHADING_TYPE7:
                 LOG.debug( "Error: Unsupported shading type " + shadingType );

Copied: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java
(from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java)
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java?p2=pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java&r1=1563199&r2=1563639&rev=1563639&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java
Sun Feb  2 15:38:41 2014
@@ -192,6 +192,8 @@ public abstract class GouraudShadingCont
                 // transform from shading to user space
                 ctm.createAffineTransform().transform(v.point, v.point);
                 // transform from user to device space
+                // move the 0,0-reference including the y-translation from user to device
space
+                v.point.setLocation(v.point.getX(), pageHeight - v.point.getY());
                 xform.transform(v.point, v.point);
             }
             else
@@ -220,7 +222,6 @@ public abstract class GouraudShadingCont
     /**
      * {@inheritDoc}
      */
-    @Override
     public void dispose()
     {
         triangleList = null;
@@ -233,7 +234,6 @@ public abstract class GouraudShadingCont
     /**
      * {@inheritDoc}
      */
-    @Override
     public final ColorModel getColorModel()
     {
         return outputColorModel;
@@ -256,7 +256,6 @@ public abstract class GouraudShadingCont
     /**
      * {@inheritDoc}
      */
-    @Override
     public final Raster getRaster(int x, int y, int w, int h)
     {
         float[] values = new float[numberOfColorComponents];

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java?rev=1563639&r1=1563638&r2=1563639&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java
Sun Feb  2 15:38:41 2014
@@ -16,11 +16,10 @@
  */
 package org.apache.pdfbox.pdmodel.graphics.shading;
 
-
-
 import java.io.IOException;
 
 import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.common.PDRange;
@@ -29,15 +28,14 @@ import org.apache.pdfbox.pdmodel.common.
 /**
  * This represents resources for a shading type 4 (Free-Form Gouraud-Shaded Triangle Meshes).
  *
- * @version $Revision: 1.0 $
  */
 public class PDShadingType4 extends PDShadingResources
 {
     
     private PDFunction function = null;
     /**
-     * An array of 2 × n numbers specifying the linear mapping of sample values 
-     * into the range appropriate for the function’s output values. 
+     * An array of 2^n numbers specifying the linear mapping of sample values 
+     * into the range appropriate for the function's output values. 
      * Default value: same as the value of Range
      */
     private COSArray decode = null;
@@ -81,7 +79,9 @@ public class PDShadingType4 extends PDSh
     {
         if (function == null)
         {
-            function = PDFunction.create(getCOSDictionary().getDictionaryObject(COSName.FUNCTION));
+            COSBase dictionaryFunctionObject = getCOSDictionary().getDictionaryObject(COSName.FUNCTION);
+            if (dictionaryFunctionObject != null)
+                function = PDFunction.create(dictionaryFunctionObject);
         }
         return function;
     }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java?rev=1563639&r1=1563638&r2=1563639&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType5.java
Sun Feb  2 15:38:41 2014
@@ -21,6 +21,7 @@ package org.apache.pdfbox.pdmodel.graphi
 import java.io.IOException;
 
 import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.common.PDRange;
@@ -29,15 +30,14 @@ import org.apache.pdfbox.pdmodel.common.
 /**
  * This represents resources for a shading type 5 (Lattice-Form Gouraud-Shaded Triangle Meshes).
  *
- * @version $Revision: 1.0 $
  */
 public class PDShadingType5 extends PDShadingResources
 {
     
     private PDFunction function = null;
     /**
-     * An array of 2 × n numbers specifying the linear mapping of sample values 
-     * into the range appropriate for the function’s output values. 
+     * An array of 2^n numbers specifying the linear mapping of sample values 
+     * into the range appropriate for the function's output values. 
      * Default value: same as the value of Range
      */
     private COSArray decode = null;
@@ -81,7 +81,9 @@ public class PDShadingType5 extends PDSh
     {
         if (function == null)
         {
-            function = PDFunction.create(getCOSDictionary().getDictionaryObject(COSName.FUNCTION));
+            COSBase dictionaryFunctionObject = getCOSDictionary().getDictionaryObject(COSName.FUNCTION);
+            if (dictionaryFunctionObject != null)
+                function = PDFunction.create(dictionaryFunctionObject);
         }
         return function;
     }

Copied: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java
(from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java)
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java?p2=pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java&r1=1563199&r2=1563639&rev=1563639&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java
Sun Feb  2 15:38:41 2014
@@ -56,7 +56,6 @@ public class Type4ShadingPaint implement
     /**
      * {@inheritDoc}
      */
-    @Override
     public int getTransparency()
     {
         return 0;
@@ -65,7 +64,6 @@ public class Type4ShadingPaint implement
     /**
      * {@inheritDoc}
      */
-    @Override
     public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
             Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
     {

Copied: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java
(from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java)
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java?p2=pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java&r1=1563199&r2=1563639&rev=1563639&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java
Sun Feb  2 15:38:41 2014
@@ -57,7 +57,6 @@ public class Type5ShadingPaint implement
     /**
      * {@inheritDoc}
      */
-    @Override
     public int getTransparency()
     {
         return 0;
@@ -66,7 +65,6 @@ public class Type5ShadingPaint implement
     /**
      * {@inheritDoc}
      */
-    @Override
     public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
             Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
     {

Copied: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java
(from r1563199, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java)
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java?p2=pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java&r1=1563199&r2=1563639&rev=1563639&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java
Sun Feb  2 15:38:41 2014
@@ -44,7 +44,7 @@ class Vertex
         String colorStr = "";
         for (float f : color)
         {
-            if (!colorStr.isEmpty())
+            if (colorStr.length() > 0)
             {
                 colorStr += " ";
             }



Mime
View raw message