Author Topic: QR code generator  (Read 511 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
QR code generator
« on: November 23, 2022, 09:50:35 AM »
Just for fun, attached a QR code generator - 72 lines of purest Assembly :biggrin:

You can supply a URL via the commandline, or you paste it in the edit box and hit Enter. Right-click into the image to save it to disk. I've tested it with Scanner QR for Android, and it works like a charm.


jack

  • Member
  • **
  • Posts: 224
Re: QR code generator
« Reply #1 on: November 23, 2022, 10:08:10 AM »
impressive jj :smiley:

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: QR code generator
« Reply #2 on: November 24, 2022, 01:51:13 AM »
Version 2, slightly improved so that longer text can be displayed: Window size and resolution will adapt to the amount of information needed.

TimoVJL

  • Member
  • *****
  • Posts: 1296
Re: QR code generator
« Reply #3 on: November 24, 2022, 02:48:14 AM »
Just have to test it :azn:
May the source be with you

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: QR code generator
« Reply #4 on: November 24, 2022, 01:03:06 PM »
Just have to test it :azn:

What is that tiny lousy website, Timo?  :biggrin:

Attached version 3 of the QR code generator; remember to right-click into the image. In case you can't see the *.asc source because you don't have WordPad or RichMasm on your machine, here is the source in plain text *.asm:



Btw with Jack's DLL there is a 2996 character limit (the source above has 2906 chars). There are several sizes reported on the web:

Quote
Model 1:
The original QR Code, a code capable of coding 1,167 numerals with its maximum version being 14 (73 x 73 modules)

Model 2
This code can encode up to 7,089 numerals with its maximum version being 40 (177 x 177 modules).

https://blinq.me/blog/what-size-should-a-qr-code-be
Quote
A QR code can store up to 4,296 alphanumeric characters of arbitrary text. The text can be anything from contact information, a URL, or even a telephone number.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: QR code generator
« Reply #5 on: November 26, 2022, 09:49:41 AM »
I've run some tests comparing:

a) Jack's version: libqrencode32Jack.dll, 62974 bytes of 22.11.22, 03:15:50
b) Timo's version: qrcodegen_na_msvcrt.lib, 4648 bytes of 25.11.22, 00:48:34

Both support strings up to 2933 bytes, Timo's version up to 2940 or so. However, the codes generated by Jack's dll are slightly more easy to recognise by my smartphone reader.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: QR code generator
« Reply #6 on: November 28, 2022, 09:10:02 AM »
Get the latest version in the ShowCase here :thumbsup:

Version 2 allows to produce multiple QR codes via a text file named QrBatch.txt, which you can drag over the exe. Its format is very simple:

Code: [Select]
HelloW.png Hello World
Line2.png This is line #2 of QrBatch.txt
Download.png http://masm32.com/board/index.php?topic=94.0
Unicode.png Unicode characters like 💪🏿😡🦾🎶☕are OK
Origin.png You got this program from http://masm32.com/board/index.php?topic=10511.0

First the file name, then a tab, followed by the text to encode, which can be Ansi, Utf8 or Utf16.