TBarcode2D_QRCode

The component is used to create the QR Code barcode symbols. It's defined in the pQRCode unit.

QR CodeA QR Code is a two-dimensional matrix symbology, readable by QR scanners, mobile phones with a camera, and smartphones. The code consists of black modules arranged in a square pattern on white background. It has position detection patterns on three of its four corners. The information encoded can be text, URL or other data.

Common in Japan, where it was created by Toyota subsidiary Denso-Wave in 1994, the QR Code is one of the most popular types of two-dimensional barcodes. Although initially used for tracking parts in vehicle manufacturing, QR Codes are now used in a much broader context, including both commercial tracking applications and convenience-oriented applications aimed at mobile phone users.

QR is the abbreviation for Quick Response, as the creator intended the code to allow its contents to be decoded at high speed.


Error checking and correcting (ECC)

There are four user-selectable levels of error correction, as shown in following table, offering the capability of recovery from the amounts of damage in the table:

Values of ECCLevel propertyECC levelsRecevory capacities (%) (approx.)
elLowestL7
elMediumM15
elQualityQ25
elHighestH30

You can use the ECCLevel property to specify the error correction code level for a QR Code symbol. It can be one of these values: elLowest, elMedium, elQuality, and elHighest, corresponding to the error checking and correcting levels L, M, Q, and H. These values are defined in the pRCode unit.

If the ECCLevelUpgrade property is set to true, the highest error correction code level that can be accommodated by current symbol size will by used for creating more robust symbols. Note, the new level is always no lower than the level specified by the ECCLevel property, and the symbol size will not be increased, it may be determined depending on the length of barcode text, and the error correction code level specified by the ECCLevel property (see also the "Symbol sizes" section below). In other words, only the remaining capacity in current symbol size will be used to upgrade the error correction code level. The property CurrentECCLevel can be used to get the factual error correction code level.


Symbol sizes

There are forty sizes of QR Code symbol. referred to as version 1 to 40, in increasing order of data capacity. You can use the MinVersion and the MaxVersion properties to specifiy the minimum and maximum sizes for a QR Code symbol. They can be one of values from 1 to 40 (defined in the pQRCode unit), corresponding to the versions 1 to 40. The smallest symbol size that accommodates the barcode text will be automatically selected between minimum and maximum symbol sizes. The CurrentVersion property can be used to get the factual symbol size.

These symbol sizes and the maximum data capacity of each version are listed in following table:

VersionSymbol size (modules)ECC levelData capacities
Numeric modeAlphanumeric modeByte modeKanji mode
121 * 21L41251710
M3420148
Q2716117
H171074
225 * 25L77473220
M63382616
Q48292012
H3420148
329 * 29L127775332
M101614226
Q77473220
H58352415
433 * 33L1871147848
M149906238
Q111674628
H82503421
537 * 37L25515410665
M2021228452
Q144876037
H106644427
641 * 41L32219513482
M25515410665
Q1781087445
H139845836
745 * 45L37022415495
M29317812275
Q2071258653
H154936439
849 * 49L461279192118
M36522115293
Q25915710866
H2021228452
953 * 53L522335230141
M432262180111
Q31218913080
H2351439860
1057 * 57L652395271167
M513311213131
Q36422115193
H28817411974
1161 * 61L772468321198
M604366251155
Q427259177109
H33120013785
1265 * 65L883535367226
M691419287177
Q489296203125
H37422715596
1369 * 69L1022619425262
M796483331204
Q580352241149
H427259177109
1473 * 73L1101667458282
M871528362223
Q621376258159
H468283194120
1577 * 77L1250758520320
M991600412254
Q703426292180
H530321220136
1681 * 81L1408854586361
M1082656450277
Q775470322198
H602365250154
1785 * 85L1548938644397
M1212734504310
Q876531364224
H674408280173
1889 * 89L17251046718442
M1346816560345
Q948574394243
H746452310191
1993 * 93L19031153792488
M1500909624384
Q1063644442272
H813493338208
2097 * 97L20611249858528
M1600970666410
Q1159702482297
H919557382235
21101 * 101L22321352929572
M17081035711438
Q1224742509314
H969587403248
22105 * 105L240914601003618
M18721134779480
Q1358823565348
H1056640439270
23109 * 109L262015881091672
M20591248857528
Q1468890611376
H1108672461284
24113 * 113L281217041171721
M21881326911561
Q1588963661407
H1228744511315
25117 * 117L305718531273784
M23951451997614
Q17181041715440
H1286779535330
26121 * 121L328319901367842
M254415421059652
Q18041094751462
H1425864593365
27125 * 125L351721321465902
M270116371125692
Q19331172805496
H1501910625385
28129 * 129L366922231528940
M285717321190732
Q20851263868534
H1581958658405
29133 * 133L3909236916281002
M303518391264778
Q21811322908559
H16771016698430
30137 * 137L4158252017321066
M328919941370843
Q23581429982604
H17821080742457
31141 * 141L4417267718401132
M348621131452894
Q247314991030634
H18971150790486
32145 * 145L4686284019521201
M369322381538947
Q267016181112684
H20221226842518
33149 * 149L4965300920681273
M3909236916281002
Q280517001168719
H21571307898553
34153 * 153L5253318321881347
M4134250617221060
Q294917871228756
H23011394958590
35157 * 157L5529335123031417
M4343263218091113
Q308118671283790
H23611431983605
36161 * 161L5836353724311496
M4588278019111176
Q324419661351832
H252415301051647
37165 * 165L6153372925631577
M4775289419891224
Q341720711423876
H262515911093673
38169 * 169L6479392726991661
M5039305420991292
Q359921811499923
H273516581139701
39173 * 173L6743408728091729
M5313322022131362
Q379122981579972
H292717741219750
40177 * 177L7089429629531817
M5596339123311435
Q3993242016631024
H305718521273784

If the barcode text does not fill the maximum data capacity of the QR Code symbol, remaining data capacity of the symbol will be filled by using PAD characters. If the barcode text is so long that it cannot be encoded using the maximum symbol size specified by the MaxVersion property, an OnInvalidLength or OnInvalidDataLength (only for Delphi/C++ Builder 2009 or later) event will occur.


Quiet zones

The minimum quiet zone is equal to 4 modules on all four sides. So the minimum values of LeadingQuietZone, TrailingQuietZone, TopQuietZone, and BottomQuietZone properties are equal to 4.


Character set

The AllowEscape property should be set to true in order to place the FNC1 characters or the ECI indicator blocks.


Escape sequences

If the AllowEscape property is set to true, following escape sequences are supported by the component, you can insert them to the barcode text:


Encoding modes

QR Code has four encoding modes as Numeric mode, Alphanumeric mode, Kanji mode and Byte mode respectively in decreasing order of encoding density. All 256 8-bits value are encoded by switching automatically between all 4 (the AllowKanjiMode property is set to true) or 3 (the Kanji mode will not be used if the AllowKanjiMode property is set to false) encoding modes. The character sets in each mode are listed in the following:

The EncodePolicy property indicates how to use these encoding mode by the component. This property can be one of these values (defined in the pQRCode unit):


Extended Channel Interpretation (ECI)

The Extended Channel Interpretation (ECI) protocol allows the output data stream to have interpretations different from that of the default character set. Four broad types of interpretations are supported in QR Code:

The ECI protocol provides a consistent method to specify particular interpretations on byte values before printing and after decoding. The ECI is identified by an integer (up to 6 digits) which is encoded in the QR Code symbol by the ECI indicator block. The escape sequence "\e[<ECI_Number>]" is used to place the ECI indicator block to the barcode text:

ECI indicator blocks may be placed anywhere in the barcode text in a single or structured append set of QR Code symbols. For example:

ABC\e[123]DEFabc\e[000003]def

The default interpretation for QR Code is ECI 000003 representing the ISO/IEC 8859-1 character set.

The AllowEscape property should be set to true in order to place the ECI indicator blocks. Any ECI invoked shall apply until the end of the barcode text, or until another ECI indicator block is encountered. Thus the interpretation of the ECI may straddle two or more symbols.


Structured append

In order to handle larger messages than are practical in a single symbol, a data message can be distributed across several QR Code symbols. Up to 16 QR Code symbols may be appended in a structured format to convey more data. If a symbol is part of a structured append this shall be indicated by a structured append block in barcode text. The escape sequence "\s[<Index>, <Amount>, <Parity>]" is used to place the structured append block to the barcode text:

The AllowEscape property should be set to true in order to place the structured append block. The structured append block may only be placed once in the barcode text. Also, it shall be placed at beginning of the barcode text. The OnInvalidChar or OnInvalidDataChar (only for Delphi/C++ Builder 2009 or later) event will occur if the structured append block be placed more than once, or it isn't placed at beginning of the barcode text. The following is the examples of structured append:

\s[2, 5, 125]ABCDEFGabcdefg1234567890


Properties:
Methods:
Events:

(*): The Data property, OnInvalidDataLength and OnInvalidDataChar events are available only for the Delphi/C++ Builder 2009 or later.

Contents