Module Qrc.Prop
QR code properties.
Except for mode_capacity
, not for the casual user.
Version
val version_of_w : int -> (version, string) Stdlib.result
version_of_w w
is the version associated to a matrix width ofw
(without the quiet zone).
val version_to_w : version -> int
version_to_w v
is the matrix width (without the quiet zone) for a QR code of versionv
. The result is between 21 to 177, increasing by 4 with each version.
Capacity
val total_bytes : version -> int
total_bytes v
is the number of bytes available to encode data in a QR code of versionv
. This includes the bytes used for error correction. For allec_level
this is equal todata_bytes
v ec_level
+ec_bytes
v ec_level
.This is ‘Total number of codewords’ in table 9 of ISO/IEC 18004:2015.
val data_bytes : version -> ec_level -> int
data_bytes v ec_level
is the number of bytes that can be used for data in a QR code of versionv
with error correction levelec_level
This is the ‘Number of data codewords’ in table 7 of ISO/IEC 18004:2015.
Warning. Encoding the data into the actual
mode
uses a few additional bytes from these bytes. Usemode_capacity
to determine the actual number of letters of the given mode you can encode in a QR code.
val ec_bytes : version -> ec_level -> int
ec_bytes v ec_level
is the number of bytes used for error correction in a QR code of versionv
with error correction levelec_level
.This is the ‘Number of error correction codewords’ in table 9 of ISO/IEC 18004:2015.
Alignment patterns
Note. The result of the functions below for `V 1
is undefined.
val align_pat_count : version -> int
align_pat_count v
is the (maximal) number of alignement patterns along one dimension; square that and retract 3 to get the total.
val align_pat_last : version -> int
align_pat_last v
is thex
coordinate of the center of the last (rightmost) alignement pattern in versionv
.
val align_pat_delta : version -> int
align_pat_delta v
is the distance between the centers of alignement patterns from right to left, or bottom to top; except for the last hop to column 6 or row 6 which absorbs the unevenness.
val align_pat_center : pat_count:int -> pat_last:int -> pat_delta:int -> int -> int
align_pat_center ~pat_count ~pat_last ~pat_delta i
is the center of thei
th alignement pattern starting from0
and counting from left to right or top to bottom.This computes the values ‘Row/Columns coordinates of center module’ in table E.1 of ISO/IEC 18004:2015.
Galois field
val field : Gf_256.t Stdlib.Lazy.t
field
is the Galois field used for error correction in QR codes, the polynomial is 0b100011101 and the generator is2
.
val gen : Gf_256.t -> ec:int -> Gf_256.byte array
gen f ec
is are the coefficients of the generator polynomial (x -g
0)·(x -g
1)·…·(x -g
ec
) withg
the generator off
andec
the number of error correcting bytes .