pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1656322 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image: JPEGFactory.java LosslessFactory.java
Date Sun, 01 Feb 2015 16:14:51 GMT
Author: tilman
Date: Sun Feb  1 16:14:51 2015
New Revision: 1656322

URL: http://svn.apache.org/r1656322
Log:
PDFBOX-2654: avoid NPE if bi.getAlphaRaster() returns null

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java?rev=1656322&r1=1656321&r2=1656322&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
Sun Feb  1 16:14:51 2015
@@ -181,6 +181,11 @@ public final class JPEGFactory extends I
                     " useful, use LosslessImageFactory instead");
         }
         WritableRaster alphaRaster = image.getAlphaRaster();
+        if (alphaRaster == null)
+        {
+            // happens sometimes (PDFBOX-2654) despite colormodel claiming to have alpha
+            return null;
+        }
         BufferedImage alphaImage = new BufferedImage(image.getWidth(), image.getHeight(),
                 BufferedImage.TYPE_BYTE_GRAY);
         alphaImage.setData(alphaRaster);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java?rev=1656322&r1=1656321&r2=1656322&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Sun Feb  1 16:14:51 2015
@@ -136,6 +136,11 @@ public class LosslessFactory
 
         // extract the alpha information
         WritableRaster alphaRaster = image.getAlphaRaster();
+        if (alphaRaster == null)
+        {
+            // happens sometimes (PDFBOX-2654) despite colormodel claiming to have alpha
+            return null;
+        }
 
         int[] pixels = alphaRaster.getPixels(0, 0,
                 alphaRaster.getSampleModel().getWidth(),



Mime
View raw message