How Java parses two-dimensional code

Source: Internet
Author: User

Package com.ust.map;
Import Java.awt.image.BufferedImage;
Import Java.io.File;
Import java.io.IOException;

Import Javax.imageio.ImageIO;

Import Jp.sourceforge.qrcode.QRCodeDecoder;
Import Jp.sourceforge.qrcode.data.QRCodeImage;
Import jp.sourceforge.qrcode.exception.DecodingFailedException;

public class Qrcodedecoderhandler {

/** * decode QR code * @param imgpath * @return string */public string Decoderqrcode (String imgpath) {//qrcode QR code picture file Fil    E imagefile = new File (Imgpath);    BufferedImage bufimg = null;    String decodeddata = null;        try {bufimg = Imageio.read (ImageFile);        Qrcodedecoder decoder = new Qrcodedecoder ();    Decodeddata = new String (Decoder.decode (New J2seimage (bufimg)));        } catch (IOException e) {System.out.println ("Error:" + e.getmessage ());    E.printstacktrace ();        } catch (Decodingfailedexception DfE) {System.out.println ("Error:" + dfe.getmessage ());    Dfe.printstacktrace (); } return decodeddata;} /** * @param args the command line arguments */public static void main (string[] args) {Qrcodedecoderhandler handler =    New Qrcodedecoderhandler ();    String Imgpath = "e://ido//Two-dimensional code//yizhicheng.png";    String decodercontent = Handler.decoderqrcode (Imgpath);    System.out.println ("Parse the result as follows:");    System.out.println (decodercontent); SyStem.out.println ("========decoder success!!!");}    Class J2seimage implements Qrcodeimage {BufferedImage bufimg;    Public J2seimage (BufferedImage bufimg) {this.bufimg = bufimg;    } public int getwidth () {return bufimg.getwidth ();    } public int getheight () {return bufimg.getheight ();    } public int GetPixel (int x, int y) {return Bufimg.getrgb (x, y); }}

}

How Java parses two-dimensional code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.