Package

Source Code of qrdecode

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;

import javax.imageio.ImageIO;

import com.google.zxing.*;
import com.google.zxing.Reader;
import com.google.zxing.client.j2se.BufferedImageMonochromeBitmapSource;

public class qrdecode
{
    public static void main (String args[]) throws Exception
    {
        File tmpfile = File.createTempFile("qrcode", ".bin");
        FileOutputStream fw = new FileOutputStream(tmpfile);
       
        for (int b = System.in.read(); b != -1; b = System.in.read())
        {
            fw.write(b);
        }
       
        fw.close();
        tmpfile.deleteOnExit();

        Reader barcodeReader = new MultiFormatReader();
        BufferedImage image = ImageIO.read(tmpfile);
        MonochromeBitmapSource source = new BufferedImageMonochromeBitmapSource(image);
       
        try
        {
            Result result = barcodeReader.decode(source);          
            System.out.println(result.getText());
            System.exit(0);
        }
       
        catch (Exception e)
        {
            System.out.println(e.toString());
            System.exit(1);
        }
    }
}
TOP

Related Classes of qrdecode

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.