mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Issue 869, handle ImageIO.write() failure per user suggestion
git-svn-id: https://zxing.googlecode.com/svn/trunk@1823 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
8a1c720221
commit
7ac5c29d97
|
@ -341,7 +341,9 @@ final class DecodeThread extends Thread {
|
|||
OutputStream outStream = null;
|
||||
try {
|
||||
outStream = new FileOutputStream(resultName);
|
||||
ImageIO.write(result, "png", outStream);
|
||||
if (!ImageIO.write(result, "png", outStream)) {
|
||||
System.err.println("Could not encode an image to " + resultName);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("Could not create " + resultName);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -62,7 +62,9 @@ public final class MatrixToImageWriter {
|
|||
public static void writeToFile(BitMatrix matrix, String format, File file)
|
||||
throws IOException {
|
||||
BufferedImage image = toBufferedImage(matrix);
|
||||
ImageIO.write(image, format, file);
|
||||
if (!ImageIO.write(image, format, file)) {
|
||||
throw new IOException("Could not write an image of format " + format + " to " + file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +75,9 @@ public final class MatrixToImageWriter {
|
|||
public static void writeToStream(BitMatrix matrix, String format, OutputStream stream)
|
||||
throws IOException {
|
||||
BufferedImage image = toBufferedImage(matrix);
|
||||
ImageIO.write(image, format, stream);
|
||||
if (!ImageIO.write(image, format, stream)) {
|
||||
throw new IOException("Could not write an image of format " + format);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue