The program
The program QR_33.htm is coded in JavaScript language to generate mask patterns and data patterns. The QR pattern is obtained by using the data that has to be encoded. The program generates a data matrix of 8-bit length scattered over a square area of 33 blocks vertical and 33 blocks horizontal. Modes are then defined first and later their corresponding data matrix array. The BCH code is also defined in the code so that there is no parity error in the generated code.
In the next part, the four error checker units L, M, Q and H are defined. The source code has been explained at places where the new functions have been declared to get a quick understanding. More details on the QR code can be found at www.denso-wave.com/qrcode/qrgene3-e.html (Denso Wave’s website). These QR codes have data encoded on both dimensions (horizontally and vertically) unlike single UPC/EAN bar codes that have data only in the horizontal direction. Hence QR codes are more efficient as these can encode data more securely in a compact grid.
Disclaimer. QR code is a 2D matrix bar code invented by Toyota’s subsidiary Denso Wave. The QR code generated in this program using JavaScript follows the rules of the original program; QR code has a free-to-use global licence. The generation of code in real time may be dependent on any other software or hardware. This program only depicts how one can create such a matrix code using JavaScript.
Download source code: click here
The author and the publisher of this program are not responsible for any mistake whatsoever and disclaim such matters pertaining to real-time usage of this program. One can use this code freely but should abide by the rules laid out at Denso Wave’s official site mentioned in the documentation of this article. The images are from Wikipedia, except for the screenshots that were generated by the QR_33.htm program.
Note. The given source code has not been colour-coded. This program has been tested on Internet Explorer 8 browser, which comes pre-installed with Windows 7 operating system. To view the colour-coded version, open the QR_33.htm code using ‘Internet Explorer 8.’ Press ‘F12’ key once the program is loaded. A ‘Developer Tool’ window then opens. In this window you can see the colour-coded version under ‘Script’ tab.
Testing steps
1. Run the QR_33.htm code (refer Fig. 3). Enter the data (EFY Enterprises Pvt Ltd)to be encoded and press ‘Generate’ button (refer Fig. 4).
2. Save it to the hard disk drive using ‘Save’ button.
3. Magnify the browser window to 1000 per cent.
4. Take a screenshot using ‘Prt Sc’ key or ‘Print Screen’ key and save the result as an image.
5. Insert the image in a Word document/Paint and crop the image to view only the code, excluding the window borders.
6. Print the code using monochrome/colour inkjet/dot-matrix/laser printer.
7. Hold the printed page in ambient light.
8. Open the QR reader app on the mobile phone having camera support. (The mobile camera can be of any resolution.) We have tested this project using Sony Ericsson WT19i mobile phone with Neoreader QR reader apps.
9. Focus the camera on the QR code image by keeping enough space all around (to be checked on the viewfinder/display).
10. Click after focusing on the image blocks (the blocks should be clearly visible).
The program on the mobile phone will now process the QR code and display the ‘EFY Enterprises Pvt Ltd’ encoded text directly on the mobile screen.
The author is a B.Tech in electronics and communications engineering, likes coding and has keen interest in space technology (satellite communications) and mobile communication