Java uses Zxing to generate a QR code

Source: Internet
Author: User

Java uses Zxing to generate a QR code. Zxing is a parsing tool provided by Google for bar code (one-dimensional code and two-dimensional code). It provides a method for generating and parsing QR codes, now I will briefly introduce the use of Java to use Zxing to generate and parse the QR code 1, the generation of the QR code 1.1 to add the Zxing-core.jar package to the classpath. 1.2 The MatrixToImageWriter class is used to generate a QR code. This class is provided by Google and can be copied to the source code. Here I paste the source code of this class and can directly use it. Import com. google. zxing. common. bitMatrix; import javax. imageio. imageIO; import java. io. file; import java. io. outputStream; import java. io. IOException; import java. awt. image. bufferedImage; public final class MatrixToImageWriter {private static final int BLACK = 0xFF000000; private static final int WHITE = 0 xFFFFFFFF; private MatrixToImageWriter () {} public static BufferedImage toBufferedImage Trix matrix) {int width = matrix. getWidth (); int height = matrix. getHeight (); BufferedImage image = new BufferedImage (width, height, BufferedImage. TYPE_INT_RGB); for (int x = 0; x <width; x ++) {for (int y = 0; y

Related Article

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.