Return-Path: Delivered-To: apmail-pdfbox-commits-archive@www.apache.org Received: (qmail 86297 invoked from network); 7 Feb 2010 15:57:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Feb 2010 15:57:44 -0000 Received: (qmail 44284 invoked by uid 500); 7 Feb 2010 15:57:44 -0000 Delivered-To: apmail-pdfbox-commits-archive@pdfbox.apache.org Received: (qmail 44258 invoked by uid 500); 7 Feb 2010 15:57:44 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 44249 invoked by uid 99); 7 Feb 2010 15:57:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Feb 2010 15:57:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Feb 2010 15:57:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 98B2423889B9; Sun, 7 Feb 2010 15:57:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r907436 - /pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDSeparation.java Date: Sun, 07 Feb 2010 15:57:23 -0000 To: commits@pdfbox.apache.org From: lehmi@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100207155723.98B2423889B9@eris.apache.org> Author: lehmi Date: Sun Feb 7 15:57:23 2010 New Revision: 907436 URL: http://svn.apache.org/viewvc?rev=907436&view=rev Log: PDFBOX-519: avoid NPE if a separation colorspace uses an other tint function than type 2. Patch by Andrew Duffy (aduffy at simiolus dot com) Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDSeparation.java Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDSeparation.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDSeparation.java?rev=907436&r1=907435&r2=907436&view=diff ============================================================================== --- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDSeparation.java (original) +++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDSeparation.java Sun Feb 7 15:57:23 2010 @@ -25,9 +25,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSBase; +import org.apache.pdfbox.cos.COSFloat; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.pdmodel.common.function.PDFunction; +import org.apache.pdfbox.pdmodel.common.function.PDFunctionType2; /** * This class represents a Separation color space. @@ -102,13 +104,7 @@ { try { - ///dump some information to help figure these things out - //logger().info( array.toString()); - PDColorSpace alt = getAlternateColorSpace(); - - //logger().info(alt.toString()); - return alt.getJavaColorSpace(); } catch (IOException ioexception) @@ -171,9 +167,6 @@ { COSBase alternate = array.getObject( 2 ); PDColorSpace cs = PDColorSpaceFactory.createColorSpace( alternate ); - - //logger().info("Returning " + cs.toString() + " for input " + alternate.toString()); - return cs; } @@ -227,12 +220,33 @@ } /** - * Returns all colorvalues for this colorspace. - * @return COSArry with all colorvalues - * @throws IOException If there is an error getting the object from the dictionary + * Returns the components of the color in the alternate colorspace for a tint value of 1.0. + * @return COSArray with the color components + * @throws IOException If the tint function is not supported */ public COSArray getColorValues() throws IOException { - return (COSArray) getDictionary().getDictionaryObject("C1"); + PDFunction tintTransform = getTintTransform(); + if(tintTransform instanceof PDFunctionType2) + { + return (COSArray) getDictionary().getDictionaryObject("C1"); + } + else + { + log.warn("Unsupported tint transformation type: "+tintTransform.getClass().getName() + + " in "+getClass().getName()+".getColorValues()" + + " using color black instead."); + int numberOfComponents = getAlternateColorSpace().getNumberOfComponents(); + // To get black as color: + // 0.0f is used for the single value(s) if the colorspace is gray or RGB based + // 1.0f is used for the single value if the colorspace is CMYK based + float colorValue = numberOfComponents == 4 ? 1.0f : 0.0f; + COSArray retval = new COSArray(); + for (int i=0;i