|
The sQuiRt library for LiveCode generates QR codes according to the ISO international standard (ISO/IEC18004).
'QR Code' is a registered trademark of DENSO WAVE INCORPORATED.
All versions (1 - 40) and all error correction levels (L, M, Q, H) are supported.
|
||||||||||||
As this library is 100% LiveCode, it is suitable for Mac, Windows, Linux, Mobile and LiveCode server platforms.
To attach sQuiRt to your project, simply open the library in LiveCode and change it's 'mainStack' property to your stack. You can use the property inspector to do this or the following line of code;
set the mainStack of stack "sQuiRt" to "MyStack"
Now save your stack and sQuiRt will be saved as a substack. The following commands show an example of using the library.
-- add the library to the message path if required if "sQuiRt" is not among the lines of the stacksInUse then start using stack "sQuiRt" end if
-- optionally use colors other than black and white
-- there must be a high enough contrast between colors for scanning -- LC color references also work : "0,0,255" instead of "Blue" qrSetColors "Blue", "Yellow"
-- create a QR code qrCreate "MyImage", "QR data", "M", 3
The parameters for the qrCreate command are;
The qrCreate command returns information in the result;
If the special character '!' is used for 'MyImage', then the result also contains the raw output of a png image. You can use this data, for example, with LiveCode server to generate QR codes on web pages.
Example using sQuiRt with LiveCode server There's an online demo at http://splash21.on-rev.com/index.lc
The following is an excerpt from the demo;
..... .....
start using stack "sQuiRt.livecode"
qrCreate "!", tData, tECC, tSize
put the result into tData
if tData begins with "Error" then
put tData
else
# line 1 of the result contains some info
# the remaining lines contain the png image data
put line 1 of tData into tInfo
delete line 1 of tData
put "<b>Qr code info</b><br/>" & LF
put "Version: " & item 1 of tInfo & "<br/>" & LF
put "ECC: " & item 2 of tInfo & "<br/>" & LF
put "Mode: " & item 3 of tInfo & "<br/>" & LF
put "Mask: " & item 4 of tInfo & "<br/>" & LF
# show the image
put base64Encode(tData) into tData
replace LF with empty in tData
put "<img src='data:image/png;base64," & tData & "'/><br/>" & LF
end if
.....
.....
|