use of jp.sourceforge.qrcode.util.DebugCanvas in project qrcode by yanbe.
the class J2SECanvas method processDecode.
static boolean processDecode(String filename, QRCodeDecoder decoder) {
DebugCanvas canvas = new J2SECanvas();
decoder.setCanvas(canvas);
BufferedImage image = null;
try {
if (filename.startsWith("http://"))
image = ImageIO.read(new URL(filename));
else
image = ImageIO.read(new File(filename));
String decodedString = new String(decoder.decode(new J2SEImage(image)));
decodedString = ContentConverter.convert(decodedString);
System.out.println(decodedString);
} catch (IOException e) {
canvas.println("Error: " + e.getMessage() + " " + filename);
return false;
} catch (DecodingFailedException dfe) {
canvas.println("Error: " + dfe.getMessage());
return false;
} catch (Exception e) {
canvas.println("Error: " + e.getMessage());
return false;
}
return true;
}
Aggregations