pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1555186 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
Date Fri, 03 Jan 2014 18:22:44 GMT
Author: lehmi
Date: Fri Jan  3 18:22:44 2014
New Revision: 1555186

URL: http://svn.apache.org/r1555186
Log:
PDFBOX-1829: avoid NPE when creating a smasked image

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java?rev=1555186&r1=1555185&r2=1555186&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
Fri Jan  3 18:22:44 2014
@@ -154,10 +154,18 @@ public abstract class PDXObjectImage ext
         if (smask != null)
         {
             BufferedImage smaskBI = smask.getRGBImage();
-            COSArray decodeArray = smask.getDecode();
-            CompositeImage compositeImage = new CompositeImage(baseImage, smaskBI);
-            BufferedImage rgbImage = compositeImage.createMaskedImage(decodeArray);
-            return rgbImage;
+            if (smaskBI != null)
+            {
+	            COSArray decodeArray = smask.getDecode();
+	            CompositeImage compositeImage = new CompositeImage(baseImage, smaskBI);
+	            BufferedImage rgbImage = compositeImage.createMaskedImage(decodeArray);
+	            return rgbImage;
+            }
+            else
+            {
+            	// this may happen if the smask is somehow broken, e.g. unsupported filter
+                LOG.warn("masking getRGBImage returned NULL");
+            }
         }
         return baseImage;
     }



Mime
View raw message