Page 1 of 2
Creating QR Code 2D bar codes
Posted: Fri Nov 25, 2016 12:41 pm
by rdonnay
This is a sample program showing how to create a QR Code BMP file.
This sample uses the MW6Tech ActiveX control.
See
https://www.mw6tech.com/qrcode/qrcode.html
This is not a free control.
The file, MW6QRCode.ZIP, contains the install program for the demo version of the ActiveX Control.
The barcode contains my name and address info.
Code: Select all
#INCLUDE "dcdialog.CH"
#Pragma Library("ascom10.lib")
FUNCTION Main()
LOCAL i, oCode, cString := ''
LOCAL nActualRows := 0, nActualCols := 0
LOCAL nActualWidth := 0, nActualHeight := 0
LOCAL nExtraWidth := 0, nExtraHeight := 0
oCode := CreateObject("MW6QRCode.QRCode")
TEXT INTO cString WRAP
Roger J. Donnay
1486 S. Loggers Pond Place
Apt. # 11
Boise, ID 83706
208-867-6091
ENDTEXT
oCode:Data := cString
// Get the actual rows and columns of QRCode barcode
oCode:GetActualRC(@nActualRows, @nActualCols)
// Get the actual QRCode barcode width and height
// The size value is based on computer screen resolution
oCode:GetActualSize( .T.,0, @nActualWidth, @nActualHeight )
IF .t.
oCode:SetSize(nActualWidth + nExtraWidth, nActualHeight + nExtraHeight)
ELSE
oCode:SetSize(nActualHeight + nExtraWidth, nActualWidth + nExtraHeight)
ENDIF
// Create a BMP file in the current folder
oCode:SaveAsBMP(DC_Path(AppName(.t.)) + "\MW6Demo.bmp")
RETURN nil
- MW6Demo.jpg (10.76 KiB) Viewed 40371 times
Re: Creating QR Code 2D bar codes
Posted: Sun Nov 27, 2016 12:00 pm
by sdenjupol148
Awesome Roger,
Now I have to figure out how I can use it.
Re: Creating QR Code 2D bar codes
Posted: Sat Mar 04, 2017 10:25 am
by unixkd
Hi Roger
I intend to explore the QR Code 2D bar codes. But would like to now a low price barcode reader supported by this activex. We are planning to print barcodes on plastic id cards for one of our applications.
Thanks.
Joe
Re: Creating QR Code 2D bar codes
Posted: Sat Mar 04, 2017 12:15 pm
by rdonnay
Code: Select all
would like to now a low price barcode reader
Are you asking for a reader that reads plastic cards?
Bobby and I recently implemented a drivers license scanner into his application.
The hardware is DuplexScan 1210. About $200 on Amazon.com.
Re: Creating QR Code 2D bar codes
Posted: Mon Apr 24, 2017 9:49 am
by Zdeno Bielik
Hi Roger,
I finally started play with sample code, but it looks that doesn’t generate correct results
just see attached picture/code and generated images/files
if you scan each qrcode and compare it with source code/text, it is not same
Where may be problem?
Zdeno
Re: Creating QR Code 2D bar codes
Posted: Mon Apr 24, 2017 10:06 am
by rdonnay
I don't have an answer for you.
I have no experience with this other than the small test program I wrote.
Re: Creating QR Code 2D bar codes
Posted: Mon Apr 24, 2017 10:49 am
by Piotr D
Zdenko
I use MW6QRCode four years. Below is, how I create these. The text, which is "QR-printed" was UTF-8 encoded.
But Alaska have problem with "transport" polish national fonts into :data slot. Author of these library make speciall for
me new method :setCharAt(char, position) which place char by char text into :data slot. With these method QR code was
created with good translation of polish national characters. Probably, you have the same problem.
Piotr
FUNCTION CreateQR_BMP(cTekst)
* Create an temporary BMP with QR code
*************************************************************
Local oControl,cFileTmp:='QR'+STRZERO(RandomInt(1,65000),5)+STRZERO(RandomInt(1,65000),5)+'.BMP',nX:=0,nY:=0,i,nVersion
oControl := XbpActiveXControl():new()
oControl:CLSID := "{3BB56637-651D-4D1D-AFA4-C0506F57EAF8}"
bOldError := ErrorBlock( {|e| Break(e)} )
BEGIN SEQUENCE
oControl:create(,, {0,0},{80,80})
RECOVER USING oError
IF oError:subCode == 6500
DC_MsgBox(,,{'UWAGA! Blad tworzenia kontrolki ActiveX.',;
'Prosze sprawdz czy zainstalowano na',;
'komputerze kontrolki MW6 QRCode.'})
QUIT
ENDIF
RETURN('')
END SEQUENCE
ErrorBlock( bOldError )
* tekst must be in UTF-8
cTekst:=cOemToUTF8(cTekst)
* rodzaj obramowania
oControl:BorderStyle:=2
* this is only for creation of :data buffer
*
oControl:Data:=cTekst
*
* Alaska send wrong "outside" text in UTF-8 (some ASCII below 128)
* In this case I don't use :data
* instead I use special method, which place into :data buffer every char by value
*
FOR i:=1 TO LEN(cTekst)
oControl:setCharAt(ASC(SUBS(cTekst,i,1)),i-1)
NEXT
* test for a size of QR code
oControl:GetActualSize(.T.,0,@nX,@nY)
oControl:destroy()
* second time the same but for correct size
oControl:create(,, {0,0},{nX,nY})
oControl:BorderStyle:=2
oControl:Data:=cTekst
FOR i:=1 TO LEN(cTekst)
oControl:setCharAt(ASC(SUBS(cTekst,i,1)),i-1)
NEXT
* save the BMP with QR in temporary file
oControl:SaveAsBMP(cFileTmp)
oControl:destroy()
i:=1
* zaczekaj, az plik powstanie
DO WHILE !FExists(cFileTmp) .AND. i<5
i:=i+1
sleep(20)
ENDDO
RETURN(cFileTMP)
Re: Creating QR Code 2D bar codes
Posted: Mon Apr 24, 2017 9:56 pm
by Zdeno Bielik
Hi Piotr,
it looks that demo version has no SetCharAt method, anyway, many thanks for sample.
If I can kindly ask you, please, can you create QR code with text bellow
and post it here – thank you.
Zdeno BIELIK
123456
tel: 12-3456
ľščŤÁÓ
čp 12.04.2017 - 32.18,-
Hello
Zdeno
oError:args :
-> VALTYPE:C VALUE:
setCharAt
-> VALTYPE:N VALUE:97
-> VALTYPE:N VALUE:0
oError:canDefault : .T.
oError:canRetry : .F.
oError:canSubstitute: .T.
oError:cargo : NIL
oError:description : Neznßmy nßzov.
Object has no method with this name
oError:filename : NIL
oError:genCode : NIL
oError:operation :
setCharAt
oError:osCode : -2147352570
oError:severity : 2
oError:subCode : 6500
oError:subSystem : Automation
oError:thread : 1
oError:tries : NIL
Re: Creating QR Code 2D bar codes
Posted: Mon Apr 24, 2017 11:42 pm
by Auge_Ohr
it does not work to copy / paste your Country special Sign from Browser to my German Environment.
try to copy Chinese Sign from Browser into your Notepad and save it ...
i have same Problem with my "QR DLL" and German "Umlaute"
- Umlaute.jpg (44.84 KiB) Viewed 32792 times
if you scan it you will see missing "Umlaute" before @ 0123456789
it seem me that most Solution use ANSI and not OEM to generate QR Code
i know there is a Chinese Version for Chinese sign -> QR Code ... but i don't know how it works
Re: Creating QR Code 2D bar codes
Posted: Tue Apr 25, 2017 2:13 am
by Piotr D
Zdenko,
send me your e-mail and I send you this library.
When I test QR-code, I find another ActiveX - Stroke Scribe. This have more possibility, have no problem
with national language (text is set as OEM, encoding to UTF-8 make these library) and is cheaper.
Below is sample.
Piotr
FUNCTION PD_CreateQR_BMP_Stroke(cTekst)
* cTekst i OEM-tekst to print
*************************************************************
Local oControl,cFileTmp:='QR'+STR(Seconds()*100,7,0)+'.BMP',nX:=0,nY:=0
oControl := XbpActiveXControl():new()
oControl:CLSID := "{7E42B8C5-73BE-4806-8904-FF4080A6960C}"
bOldError := ErrorBlock( {|e| Break(e)} )
BEGIN SEQUENCE
oControl:create(,, {0,0},{80,80})
RECOVER USING oError
IF oError:subCode == 6500
DC_MsgBox(,,{'UWAGA! BĄd tworzenia kontrolki ActiveX.',;
'Prosz© sprawd« czy zainstalowano na',;
'komputerze kontrolki Stroke Scribe.'})
QUIT
ENDIF
RETURN('')
END SEQUENCE
ErrorBlock( bOldError )
* select printing QR
oControl:Alphabet:=25
* text to print
oControl:Text:=cTekst
* set UTF-8 encoding.
oControl:UTF8:=.T.
* size of bitmap
nX:=oControl:BitmapH
* now can I create
oControl:destroy()
oControl:create(,, {0,0},{nx,nx})
oControl:Alphabet:=25
oControl:Text:=cTekst
oControl:UTF8:=.T.
oControl:CopyToClipboard()
oControl:SavePicture(cFileTmp,0,nX,nX,0)
oControl:destroy()
RETURN(cFileTMP)