How to insert images in QR code

Source: Internet
Author: User

The QR code has finally become fire. Now the QR code labels on the advertisements of large and small commodities in the streets are everywhere, and most of them are not pure QR codes, but the QR codes with personalized icons in the middle.

I have previously developed a program that uses the google open-source project zxing to implement QR code and one-dimensional code decoding, and opened the source code (code and QR code decoder implemented using C ), today, we continue to add small images in the middle of the QR code based on this program.

Background

QRcode uses the Reed-Solomon Code for error correction. For us, Reed-Solomon encoding has two very important features. First, it is an explicit system code, that is, you can directly see the original information in the final code. It is like coding "hello world". We finally see "hello world" and several fault-tolerant codes that follow it. Second, the Reed-Solomon Code can be "exclusive or", and a new Reed-Solomon Code will be obtained after two XOR operations are performed on the results of two different Reed-Solomon Codes, and the original code of the new Code is the same or different of the original two original codes. If you want to know why these two features are true, see Finite Field Arithmetic and Reed-Solomon Coding.

QRcode

A QRcode image defines some unique descriptors to help people or computers identify themselves as a QRcode. This descriptor varies slightly with the QRcode size-the larger the QRcode image has more descriptors. However, for human identification, the most obvious feature is that the four corners of the image are fixed. When we see these four corners, humans will instinctively respond: This is a QRcode.

(In fact, we can read the two pixel points in the top left corner of the image to determine the degree of redundancy. It is defined as 0 in black and 1 in white. If 00 is displayed, it indicates L-level redundancy. 01 indicates M, 10 indicates Q, and 11 indicates H-level redundancy.

With the above work, we can easily know the position of the original code information in the image. Then, by changing your original code information, you can change the pixels in the image so that you can map them in it. However, the following situations can make things more interesting.

 

I made a QR code to insert an image:

Previously, I provided a QR code decoder transformed from the zxing open source project for free, but failed to insert images. After some efforts, the image is inserted into the QR code and can be encoded and decoded. The key to inserting an image is to adjust the fault tolerance coefficient of the QR code, which is described in detail in the source code.

Interface:

 

You need to insert an image into the QR code and the image can be decoded properly.

Detailed comments are provided in the source code.

 

QR code and image source code: http://www.51aspx.com/code/QRWithPicture/19074

 

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.