Announcement

Collapse
No announcement yet.

How to "draw" a QR CODE?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to "draw" a QR CODE?

    Anyone run into a way to "DRAW" a QR CODE?

    I'm looking for an explanation of how to draw one. And much thanks to Rod Macia for his GoogleAuthenticator code!!!

    I am figuring I could draw one as a graphic in memory then display it on a web page....


  • #2
    Which of the 57 types do you want to generate?
    Model 1 (Ver 1 to 14) or Model 2 (Ver 1 to 40) ?
    Or maybe Micro QR(Ver 11,13,15) ?
    Are you familiar with Reed-Solomon error correction encoding which is applied to the data?

    Once you've got that sorted out, it's just a case of drawing approrpaite blocks in the correct locations within the square for the Alignement pattern, timiing pattern and format information.
    Then all you need to do is draw the blocks for the data and error correction symbols in the correct sequential locations as per:

    Click image for larger version  Name:	QRBlocks.jpg Views:	0 Size:	82.9 KB ID:	815928

    Personally, I'd just grab a copy of https://www.nirsoft.net/utils/qr_code_generator.html
    and SHELL to it to generate a QR graphic.

    SimpleCodeGenerator is a simple tool for Windows that allows you to quickly generate QR Code for scanning with App on your Smartphone. You can display the QR Code on the screen, copy it to the clipboard and then paste it to another program (as image), or save it image file - .png , .gif , .jpg , .tiff, or .bmp

    SimpleCodeGenerator also allows you to generate QR Code from command line and save it as image file ( .png , .gif , .jpg , .tiff, or .bmp) without displaying any user interface.


    At 65KB, you could embed that application as RCDATA in your main application, extract it to a temp directory and shell to it to generate the graphic


    Comment


    • #3
      An other option using Zint Barcode Generator
      https://forum.powerbasic.com/forum/u...code-generator

      Comment


      • #4
        Simple demo using the Nirsoft application to display the code and also place it on the Clipboard
        '
        Code:
        #COMPILE EXE
        #DIM ALL
        %UNICODE = 1
        #INCLUDE ONCE "WIN32API.INC"
        #RESOURCE RCDATA QRGen "SimpleCodeGenerator.exe"
        FUNCTION PBMAIN() AS LONG
            LOCAL ff AS LONG
            LOCAL strRes AS STRING
            LOCAL wstrFile,wstrQR,wstrShell  AS WSTRING
            LOCAL wstrTemploc, wstrApploc AS WSTRINGZ * %MAX_PATH
        
            'Save generator in temp directory
            GetTempPath(%MAX_PATH, wstrTempLoc)
            wstrAppLoc = wstrTempLoc &  "SimpleCodeGenerator.exe"
            strRes = RESOURCE$(RCDATA,"QRGen")
            ff = FREEFILE
            IF ISFILE(wstrAppLoc) THEN KILL wstrApploc
            OPEN wstrAppLoc FOR BINARY AS #ff
            PUT$ #ff ,strRes
            CLOSE #ff
        
            'Generate QRCode
            wstrFile = wstrTemploc & "myQRCode.bmp"
            wstrQR =  "Stuart McLachan\r\nCAMCO Ltd\r\nPort Moresby\r\nhttps://www.camcopng.com" 'multi line!
            wstrShell = CHR$(wstrAppLoc," /ErrorCorrection 2 /MinVersion 1 /MaxVersion 40 /Save ",$DQ,wstrQR,$DQ,32,$DQ,wstrFile,$DQ)
            SHELL wstrShell
        
            'Use the QRCode bitmap file
            GetQRCode(wstrFile)
        
            'Cleanup
            KILL wstrApploc
            KILL wstrFile
        END FUNCTION
        
        FUNCTION GetQRCode(Sfile AS WSTRING) AS LONG
            LOCAL hGraph,hBmp AS LONG
            GRAPHIC BITMAP LOAD sFile,0,0 TO hBmp
            
            CLIPBOARD RESET
            CLIPBOARD SET BITMAP hBmp
        
            GRAPHIC WINDOW NEW "My QR Code",200,100,500,500 TO hGraph
            GRAPHIC ATTACH hGraph,0
            GRAPHIC STRETCH PAGE  hBmp,0
            GRAPHIC WAITKEY$
            GRAPHIC WINDOW END hGraph
        END FUNCTION
        '
        Click image for larger version  Name:	MyQRCode.jpg Views:	0 Size:	26.1 KB ID:	815934
        Last edited by Stuart McLachlan; 11 Apr 2022, 03:50 AM.

        Comment


        • #5
          Both read and write.

          https://www.codetwo.com/freeware/qr-...ader/?sts=1375

          Click image for larger version

Name:	qrcode.png
Views:	241
Size:	504 Bytes
ID:	815935
          Last edited by Steve Hutchesson; 11 Apr 2022, 03:56 AM.
          hutch at movsd dot com
          The MASM Forum - SLL Modules and PB Libraries

          http://www.masm32.com/board/index.php?board=69.0

          Comment


          • #6
            In case you like to convert some C++ code on the topic.

            https://github.com/nayuki/QR-Code-ge...ree/master/cpp
            So here we are, this is the end.
            But all that dies, is born again.
            - From The Ashes (In This Moment)

            Comment


            • #7
              Wow! Thank You!

              Comment

              Working...
              X