Fixed NullPointerException cases on snapshot images parsing.

pull/135/head
luccioman 7 years ago
parent 285f0d6a39
commit a17a418e78

@ -304,6 +304,10 @@ public class snapshot {
Image image;
try {
image = ImageParser.parse(imageFile.getAbsolutePath(), FileUtils.read(imageFile));
if(image == null) {
/* Should not happen. If so, ImageParser.parse() should already have logged about the error */
return null;
}
final Image scaled = image.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING);
final MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(scaled, 0);

@ -199,7 +199,11 @@ public class Html2Image {
try {
File newPngFile = new File(pngFile.getAbsolutePath() + ".png");
pngFile.renameTo(newPngFile);
Image img = ImageParser.parse(pngFile.getAbsolutePath(), FileUtils.read(newPngFile));
final Image img = ImageParser.parse(pngFile.getAbsolutePath(), FileUtils.read(newPngFile));
if(img == null) {
/* Should not happen. If so, ImageParser.parse() should already have logged about the error */
return false;
}
final Image scaled = img.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING);
final MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(scaled, 0);

Loading…
Cancel
Save