Fix possible NullPointerException with invalid/unsupported image types

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1725332 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-01-18 19:56:30 +00:00
parent 0173f22787
commit fe359afec3
2 changed files with 7 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import java.awt.RadialGradientPaint;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -145,8 +146,13 @@ public class DrawPaint {
renderer.setAlpha(alpha/100000.f); renderer.setAlpha(alpha/100000.f);
} }
BufferedImage image = renderer.getImage();
if(image == null) {
LOG.log(POILogger.ERROR, "Can't load image data");
return null;
}
Rectangle2D textAnchor = shape.getAnchor(); Rectangle2D textAnchor = shape.getAnchor();
Paint paint = new java.awt.TexturePaint(renderer.getImage(), textAnchor); Paint paint = new java.awt.TexturePaint(image, textAnchor);
return paint; return paint;
} }