Search in sources :

Example 1 with DebugCanvas

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;
}
Also used : IOException(java.io.IOException) DebugCanvas(jp.sourceforge.qrcode.util.DebugCanvas) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) URL(java.net.URL) DecodingFailedException(jp.sourceforge.qrcode.exception.DecodingFailedException) IOException(java.io.IOException) InvalidVersionInfoException(jp.sourceforge.qrcode.exception.InvalidVersionInfoException) DecodingFailedException(jp.sourceforge.qrcode.exception.DecodingFailedException)

Aggregations

BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 DecodingFailedException (jp.sourceforge.qrcode.exception.DecodingFailedException)1 InvalidVersionInfoException (jp.sourceforge.qrcode.exception.InvalidVersionInfoException)1 DebugCanvas (jp.sourceforge.qrcode.util.DebugCanvas)1