Create QRCode (2D-Barcode)

Share your advanced PureBasic knowledge/code with the community.
loulou2522
Enthusiast
Enthusiast
Posts: 501
Joined: Tue Oct 14, 2014 12:09 pm

Re: Create QRCode (2D-Barcode)

Post by loulou2522 »

infratec wrote: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
Thanks infratec I will try to see if the qrcode is readable after including another image
loulou2522
Enthusiast
Enthusiast
Posts: 501
Joined: Tue Oct 14, 2014 12:09 pm

Re: Create QRCode (2D-Barcode)

Post by loulou2522 »

Can someone help me on How to decode a qrcode with Purebasic. With zbarimg some image can be decodeand other one no
THanks
dige
Addict
Addict
Posts: 1254
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Create QRCode (2D-Barcode)

Post by dige »

Could you please provide us an image?
I have tested ZBar and Pb 5.73B3 x86 and everything seems to work..
"Daddy, I'll run faster, then it is not so far..."
loulou2522
Enthusiast
Enthusiast
Posts: 501
Joined: Tue Oct 14, 2014 12:09 pm

Re: Create QRCode (2D-Barcode)

Post by loulou2522 »

Extraction de l'image faite avec PDFImages

Image

LIens
http://www.sepa-convertir.ch/utilitaire ... cture2.pdf
http://www.sepa-convertir.ch/utilitaire ... /toto2.png

the PDF invoice2.pdf has been processed with PDFCAIRO and the result can be found in
Resultat dans toto.png
Phaseun

Code: Select all

pdftocairo -png -cropbox -x 380 -y 1220 -H 300 -W 298 -gray -transp facture2.pdf

zbarimg.exe -D toto.png
Hoping that this will be enough for you
infratec
Always Here
Always Here
Posts: 6874
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Create QRCode (2D-Barcode)

Post by infratec »

I told you already that the quality of the image inside of the PDF is bad and the extracted image is even worse.

You have to put the generated code in 100% quality inside the PDF.
loulou2522
Enthusiast
Enthusiast
Posts: 501
Joined: Tue Oct 14, 2014 12:09 pm

Re: Create QRCode (2D-Barcode)

Post by loulou2522 »

infratec wrote:I told you already that the quality of the image inside of the PDF is bad and the extracted image is even worse.

You have to put the generated code in 100% quality inside the PDF.
I know that. I tried to improve the quality of the PDF with GHOSTSCRIPT but it doesn't work. The problem I have is related to ZBARIMAGE (problem already raised in 2017 on the ZBAR forum but not solved to date)
For your information, the file facture2.pdf comes from the validation site of SIX Switzerland, which means that I don't have the hand on the creation of this PDF. I have to treat it as it is. What I don't understand is that software like PDFCandy treats the conversion of the PDF facture2 without any problem into PNG and then the PNG is treated as a QRCODE.

Have you a solution to generated code in 100% quality inside the PDF. ?
I am ready to buy a command line tools for converting PDF into QRCODE via img
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Create QRCode (2D-Barcode)

Post by Marc56us »

... converting PDF into QRCODE via img...
The PDF format is simply an encapsulation of elements. Text is converted, but images remain in their original format (jpg, bmp, png etc). It is thus enough to extract the whole (provided that the elements are not encrypted).
Do not try to convert a whole PDF file into a single image: this is the worst way to destroy the quality of the original images, thus making QRCodes unreadable.

Extract images from PDF file: There are free tools that do it very well
One of them (freeware)
https://www.pdfarea.com/PDF-Image-Extractor.htm
(There are also probably some available on the command line.)
It does extract the QRCode given in your example. But I was only able to read it one time out of 10 with my phone (while all the other QRCodes I usually read work).

@loulou2522
You had to create another topic, because your question is about reading and not about creating a QRCode :wink:
Post Reply