Create QRCode (2D-Barcode)

Share your advanced PureBasic knowledge/code with the community.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: Create QRCode (2D-Barcode)

Post by NoahPhense »

jassing wrote:did you create the lib as indicated before your 1st post?
Sure did. I will try it again, for fun.

** still no go **

I have the DLL, created the lib.. do I need to register the DLL or the lib .. ?
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Create QRCode (2D-Barcode)

Post by applePi »

Hi
here is what i have done since i have beta 8 also and works okay.
1- download QrcodeXtra.7z from https://docs.google.com/leaf?id=0B_EW83 ... ist&num=50 mentioned above, you may need google chrome
2-and as jack said copy qrcodelib.dll to C:\PureBasic\Compilers and from prompt : polib qrcodelib.dll /machine:ix86 /out:qrcodelib.lib
so now the qrcodelib.dll and qrcodelib.lib in c:\purebasic\compilers folder.
3- edit the code above line 20 so it is:
ImportC "qrcodelib.lib"
instead of ImportC "..\Lib\qrcodelib.lib"
run it click on size
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: Create QRCode (2D-Barcode)

Post by NoahPhense »

applePi wrote:Hi
here is what i have done since i have beta 8 also and works okay.
1- download QrcodeXtra.7z from https://docs.google.com/leaf?id=0B_EW83 ... ist&num=50 mentioned above, you may need google chrome
2-and as jack said copy qrcodelib.dll to C:\PureBasic\Compilers and from prompt : polib qrcodelib.dll /machine:ix86 /out:qrcodelib.lib
so now the qrcodelib.dll and qrcodelib.lib in c:\purebasic\compilers folder.
3- edit the code above line 20 so it is:
ImportC "qrcodelib.lib"
instead of ImportC "..\Lib\qrcodelib.lib"
run it click on size
Thanks, it turns out that I was libbing a different version of the DLL than the one in that google docs download. Should be noted.

** and ps, you don't need to leave it in the compilers dir.. the app directory is fine.

- np
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Create QRCode (2D-Barcode)

Post by Keya »

hello does anyone have 64bit libs?
thanks dige for the demo!!! :)
User avatar
tj1010
Enthusiast
Enthusiast
Posts: 621
Joined: Mon Feb 25, 2013 5:51 pm
Location: US or Estonia
Contact:

Re: Create QRCode (2D-Barcode)

Post by tj1010 »

The reason it's hard to write a scanner is because you have to deal with noise and light levels when you get data from something like avicap32.dll. Getting dimension and angle using markers then decoding isn't that complex. Generating is just following the spec which uses only black and white and ninety degree vector shapes in proportion of markers.

Mobile devs have CIDetectorTypeQRCode for IOS and Barcode API for Android which is why everyone has a QR scan feature without knowing how it works..

I've yet to see a static scan lib on x86 though which sucks because QR is a fast air-gapped method for copy and paste.. I've transferred source code using it in seconds before..
The truth hurts.
bhatkins2000
New User
New User
Posts: 9
Joined: Fri Apr 28, 2006 4:20 pm
Location: Missouri

Re: Create QRCode (2D-Barcode)

Post by bhatkins2000 »

I was able to create a program using Dige's code (thank you) that creates a scannable QR Code. It works fine from the compiled code but fails to start as an executable with the following error message:

The program can't start because qrcodelib.dll is missing from your computer. Try reinstalling the program to fix this problem.

I have both qrcodelib.lib and qrcodelib.dll in the compiler folder.

Any guesses as to what I'm doing wrong? Any help would be appreciated.

I'm using Purebasic 5.60 on WIndows 7 Ultimate and W10 Pro
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Re: Create QRCode (2D-Barcode)

Post by yrreti »

I am having the same issue as bhatkins2000, and get the same error message.

I am using PureBasic 5.72
and use the following code

Code: Select all

ImportC "qrcodelib.lib"
QRcode_encodeString8bit(Text.p-ascii, Version.l, QRecLevel.l) As "_QRcode_encodeString8bit"
QRcode_free(*Qrcode.QRCode) As "_QRcode_free"
EndImport
which works fine as long as I am using the purebasic compiler IDE mode.
But when I compile and create an executable program, it always errors out with:
The program can't start because qrcodelib.dll is missing from your computer. Try reinstalling the program to fix this problem.

Correct me please if I am wrong.
I think the problem is that qrcodelib.lib is just imported when using the purebasic compiler IDE mode.
But is not added into the program when creating an executable, as the qrcodelib.dll files location doesn't exist anymore
as far as the executable program can see. Is there a way with PB to actually be able to create the executable with
the qrcodelib.dl file actually compiled into the exe ? Or if the lib file has to be located in the same directory as the executable,
to be able to compile it to load it from there?
As said above by bhatkins2000, Any help would be much much appreciated.
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Re: Create QRCode (2D-Barcode)

Post by yrreti »

Experimented and found the solution

Just remove qrcodelib.dll and qrcodelib.lib out of you compiler directory and place them in your
programs code directory. Then change the previous ImportC code to reflect that new location.

eg: My programs directory is : D:\MyPB_pgms\QrCode

Code: Select all

ImportC "D:\MyPB_pgms\QrCode\qrcodelib.lib"
QRcode_encodeString8bit(Text.p-ascii, Version.l, QRecLevel.l) As "_QRcode_encodeString8bit"
QRcode_free(*Qrcode.QRCode) As "_QRcode_free"
EndImport
Now I can compile and run the code under the IDE,
and also compile it to a working exe file.
You just need to always include the qrcodelib.dll and qrcodelib.lib in the same directory
as your executable in order to run it. But at least it works.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Create QRCode (2D-Barcode)

Post by Marc56us »

5.72 LTS Windows x64

This works well with PB x86 version, but not with the x64 version.

Code: Select all

[ERROR] Invalid memory access. (read error at address 18446744073709551615)
(Line where debug stop)

Code: Select all

*Qrcode = QRcode_encodeString8bit(content, 0, EC_Level)
Is it possible to modify the code or is it a limitation of the lib?

qrcodelib.dll (x86 ?) 2012/10/11.
Is there a 64 version of this lib since this from 2011 ?

Some updates 2018
https://fukuchi.org/works/qrencode/
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Re: Create QRCode (2D-Barcode)

Post by yrreti »

Hi Marc56us
Your right. It's a 32 bit lib, so it won't compile under a 64bit program compiler.
Yet it works real well on my Windows 10 64bit Desktop, that I didn't even try to compile it because of that.

Thanks very much for that link though.
It looks very interesting, and I may look more into that later.
But right now I am just too tied up with many things.
I just needed to get the 32 bit one working asap for a immediately needed project.
At least you are able to use the 32 bit program for the time being.
If and when I do get some free time, I will post what I've found here.
Hopefully someone else may be able to help you with this question in the mean time.
Sorry.
loulou2522
Enthusiast
Enthusiast
Posts: 495
Joined: Tue Oct 14, 2014 12:09 pm

Re: Create QRCode (2D-Barcode)

Post by loulou2522 »

Dige,
How can i integrate the swiss croos image at the center of the qrcode.
Thanks in advance
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Create QRCode (2D-Barcode)

Post by dige »

loulou2522 wrote:Dige,
How can i integrate the swiss croos image at the center of the qrcode.
Thanks in advance
Sorry, I do not understand what you mean. :?
"Daddy, I'll run faster, then it is not so far..."
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Create QRCode (2D-Barcode)

Post by infratec »

That's easy:

Create the QR code with highest 'errorlevel'.
This allows 30% damages.
Than you can overwrite the generated image with your logo.
(If it is not using more than 30% of the code)

But you have to test the readability :wink:
loulou2522
Enthusiast
Enthusiast
Posts: 495
Joined: Tue Oct 14, 2014 12:09 pm

Re: Create QRCode (2D-Barcode)

Post by loulou2522 »

infratec wrote:That's easy:

Create the QR code with highest 'errorlevel'.
This allows 30% damages.
Than you can overwrite the generated image with your logo.
(If it is not using more than 30% of the code)

But you have to test the readability :wink:
How can i owerwrite the generated image ? Please can you give me an example.
Thanks
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Create QRCode (2D-Barcode)

Post by infratec »

That's very 'Basic' :mrgreen:

Code: Select all

If OpenWindow(0, 0, 0, 400, 100, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If LoadImage(0, #PB_Compiler_Home + "Examples\Sources\Data\PureBasicLogo.bmp")
    
    If CreateImage(1, 80, 50, 24, #Red)
      
      If StartDrawing(ImageOutput(0))
        DrawImage(ImageID(1), 80, 15)
        StopDrawing()
      EndIf
    EndIf
    
    ImageGadget(0,  10, 10, 0, 0, ImageID(0))
  EndIf
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Post Reply