You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2011/02/26 10:36:23 UTC

svn commit: r1074810 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf: PDFICCBasedColorSpace.java PDFICCStream.java

Author: jeremias
Date: Sat Feb 26 09:36:23 2011
New Revision: 1074810

URL: http://svn.apache.org/viewvc?rev=1074810&view=rev
Log:
Fix for a potential NPE when painting vector graphics with non-sRGB colors.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCStream.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java?rev=1074810&r1=1074809&r2=1074810&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java Sat Feb 26 09:36:23 2011
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.io.IOUtils;
+
 import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
 
 /**
@@ -34,6 +35,7 @@ public class PDFICCBasedColorSpace exten
 
     private PDFICCStream iccStream;
     private String explicitName;
+    private int numComponents;
 
     /**
      * Constructs a the ICCBased color space with an explicit name (ex. "DefaultRGB").
@@ -43,6 +45,7 @@ public class PDFICCBasedColorSpace exten
     public PDFICCBasedColorSpace(String explicitName, PDFICCStream iccStream) {
         this.explicitName = explicitName;
         this.iccStream = iccStream;
+        this.numComponents = iccStream.getICCProfile().getNumComponents();
     }
 
     /**
@@ -60,7 +63,7 @@ public class PDFICCBasedColorSpace exten
 
     /** {@inheritDoc} */
     public int getNumComponents() {
-        return iccStream.getICCProfile().getNumComponents();
+        return this.numComponents;
     }
 
     /** {@inheritDoc} */
@@ -93,6 +96,7 @@ public class PDFICCBasedColorSpace exten
     }
 
     /** {@inheritDoc} */
+    @Override
     protected String toPDFString() {
         StringBuffer sb = new StringBuffer(64);
         sb.append(getObjectID());

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCStream.java?rev=1074810&r1=1074809&r2=1074810&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCStream.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFICCStream.java Sat Feb 26 09:36:23 2011
@@ -49,7 +49,11 @@ public class PDFICCStream extends PDFStr
         pdfColorSpace = alt;
     }
 
-    /** @return the ICC profile */
+    /**
+     * Returns the associated ICC profile. Note that this will return null once the
+     * ICC stream has been written to the PDF file.
+     * @return the ICC profile (or null if the stream has already been written)
+     */
     public ICC_Profile getICCProfile() {
         return this.cp;
     }
@@ -59,6 +63,7 @@ public class PDFICCStream extends PDFStr
      * byte arrays around so much
      * {@inheritDoc}
      */
+    @Override
     protected int output(java.io.OutputStream stream)
                 throws java.io.IOException {
         int length = super.output(stream);
@@ -67,11 +72,13 @@ public class PDFICCStream extends PDFStr
     }
 
     /** {@inheritDoc} */
+    @Override
     protected void outputRawStreamData(OutputStream out) throws IOException {
         cp.write(out);
     }
 
     /** {@inheritDoc} */
+    @Override
     protected void populateStreamDict(Object lengthEntry) {
         put("N", cp.getNumComponents());
         if (pdfColorSpace != null) {



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