Don't crash on unsupported barcode format like CODE_93

git-svn-id: https://zxing.googlecode.com/svn/trunk@2266 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-04-26 17:15:28 +00:00
parent 18c3b38a9a
commit 5af1cad965

View file

@ -313,7 +313,13 @@ final class QRCodeEncoder {
hints.put(EncodeHintType.CHARACTER_SET, encoding);
}
MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix result = writer.encode(contentsToEncode, format, dimension, dimension, hints);
BitMatrix result;
try {
result = writer.encode(contentsToEncode, format, dimension, dimension, hints);
} catch (IllegalArgumentException iae) {
// Unsupported format
return null;
}
int width = result.getWidth();
int height = result.getHeight();
int[] pixels = new int[width * height];