New Component: Barcode_QR

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

Over a year ago we published an article about a Barcode_128 bar code generator component. In response to that article, some users requested a QR code generator component. QR Code (Quick Response Code) is a popular two dimensional matrix bar code that was invented by Denso in 1994. It has since become an ISO/IEC standard.

QR Code readers are freely available for iPhone, Android and other smart devices. Using a reader to read a QR Code allows information to be easily entered into the smart device without the tedium of having to use a small cramped keyboard. The information could include website URL, phone number, physical address, order, part number or contact information.

The QR code below contains the text: “http://www.swishzone.com”

Most QR readers recognize a website name and offer to open a browser window that refers to the site. If you have a mobile device with a QR code reader installed (eg. ZXing) you should be able to scan the image and then optionally browse the swishzone.com website.

QR Codes are a convenient way to publicize your website or business to mobile devices through conventional media: Posters, billboards, stickers, T-Shirts or other merchandising goods.

A QR code in a shop window is a great way for people to obtain information about your business from its mobile website if they arrive after normal business hours.

QR Codes are also a convenient way to allow the transfer the URL of a mobile specific website from a desktop computer into a mobile device.

The QR component described by this article allows users to create their own QR Codes.

Downloads

The component will work with SWiSH Max4 and miniMax4 with build dates of 20110620 or later, although the component is not included with the 20110620 build’s installer, it can be downloaded here. After downloading, extract the files within the zip file to:

C:\Program Files\SWiSH Max4\Components\Utility

Note that the exact location may be different depending on where you installed Max4, or miniMax4. We intend including the component in future releases of Max4 and miniMax4. On x64 systems, Max4 and miniMax4 are by default installed into C:\Program Files (x86)\…

Use

To use the component, drag Barcode_QR onto the stage then manually enter a string into the Parameters panel. Alternatively, use the Set_QR(s) method to create a new code using script.

The sample movie below demonstrates the use of the Set_QR(s) method. It also demonstrates how the component can be used as a mask to provide a QR code that is colored according to a color gradient. This can make your codes a little more interesting than the common black and white ones that are typically used. Using the masking method you could also use images in place of the gradient, however the image should not contain any white areas.

Parameters

String

This is the string that is encoded into the QR code. The string can be altered using script via the Set_QR() method.

Color

This is the color of the QR code. It should be a dark color to maximize contrast. Black is commonly chosen.

Background Color

This is the background color of the QR code. A light color, generally white should be chosen. If using the component as a mask, choose 0% alpha to allow masking to work correctly.

Size

This is the size of the code when displayed. The interpretation of this value depends on the Variable Size checkbox.

Variable Size

If this check box is un checked, then the QR code size is defined by the size value. ie, 250 means a 250 by 250 pixel code.

If this is checked, then the size represents the size of an individual square within the matrix. The overall matrix size is varible and is defined by the amount of data that is encoded into the QR code.

Methods

SetQR(s)

The QR code is updated to display the new string. If the string cannot be displayed because it is too long, -1 is returned.

GetMode(s)

The QR code standard defines a number of versions, different data types and error correction modes. This Method returns the version, data type and correction mode information in a number that can be interpreted as a bitmap of VVVVEECC. You will need to convert the number to binary to interpret the bit map.

Where vvvv is the version number
ee = error correction mode 0=L, 1=M, 2=Q, 3=H
cc = coding method 0=numeric, 1=alpha numeric, 2=8bit

During typical use, this method need not be used. It is only provided for those that are interested and want more information about the codes that are being created.

Settings(col,bgndcol,size,variablesize)

This method allows the remaining parameter settings to be altered using script.

Technical Information

The QR Standard defines a number of versions, Version 1 to Version 40. The higher the version number, the more data can be stored. The size of the matrix is implied by the version number according to the formula:

s = 17+n*4 where n is the version number.

For example: A Version 3 QR code has s=17+3*4 = 29. indicating matrix of 29 x 29.

A Version 40 QR code (177 x 177) can encode up to 2953 bytes. However, because of the size and complexity of the matrix, this code is generally not readable by mobile devices – a specialist scanner is usually required. QR code versions below 5 are generally easily read by a mobile device.

Different levels of error correction can be applied to the data before it is encoded. The specification defines 4 levels of correction: L, M, Q and H were L is the lowest level and H is the highest. As the level of correction is increased, the amount of data that can be encoded is decreased.

The specification also supports 4 different data types:

  • Numeric – digits 0..9
  • Alpha Numeric – Upper case A..Z, digits 0..9 and the symbols space $ % * + – . / :
  • Byte – an 8 bit byte. Any ascii symbol can be encoded.
  • Kanji/Kana – Japanese script characters.

The number of symbols that can be encoded into a given size matrix depends on the chosen data type. Selecting a data type that closely matches the intended data may result in a more efficient coding.

For example, using Numeric instead of the Byte data type to encode numeric data can result in better data packing and smaller bar codes.

The Barcode_QR component selects the best data type based on the entered data. Currently the Kanjii / Kana datatype is not supported. It then encodes the data using up to version 3 with M error correction. This means that the maximum number of symbols that can be encoded is shown in the table below:

Data Type Maximum Description
Numeric 149 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Alpha Numeric 61 0-9, A-Z (upper case only), space, $, %, *, +, -, ., /, :
Byte 42 8 bit bytes. Entire ascii character set possible

URL names longer than the 42 character maximum can be shortened using a shorten and re-direct website such as google’s URL shortener.

If you need to print the URL that has been created, consider using the PrintJob script command.

Tags: , , , ,

8 Responses to “New Component: Barcode_QR”

  1. [...] some users requested a QR code generator component. QR Code (Quick Response Code) …See on blog.swishzone.com Share [...]

  2. Emanuele says:

    Hi,

    I compared QR codes generated by your component and by other online services like http://goqr.me/
    It seems that resulting images are quite different.
    Obviously I tried using various parameters, but no one matches the SwishMax QR component.
    Any idea?

    • jonh says:

      The actual QR code can be altered by a number of factors including the choice of the error correction level, L, M, Q or H and the chosen data type. “123″ can be encoded using Numeric, Alphanumeic or Binary data types. In addition, masks can be applied to the data to provide a “better” data pattern. The choice of mask is arbitrary and up to the person generating the code. A “better” data pattern is a pattern that minimizes the number of consecutive dark or light sections.

  3. Emanuele says:

    Many thanks for your reply.

    Because actually I have not a QR reader in my hand, I would only be sure that the URL content is correctly interpreted by the reader, despite the mask used.

  4. niewaznejak says:

    Thank you, I waited this long!

  5. Hello, Neat post. There is a problem along with your site in web explorer, would check this? IE still is the market leader and a huge part of people will miss your magnificent writing due to this problem.

  6. Nice gadget, but I’m wondering how many people really do anything with the QR codes. I think it’s most interesting for very long domain names, but otherwise it’s just as easy to just type in the address…


Switch to our mobile site