Skip to content

Xor-el/QRCodeGenLib4Pascal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QRCodeGenLib4Pascal logo

QRCodeGenLib4Pascal

Build Status License: MIT Delphi XE3+ FreePascal 3.0.0+


QRCodeGenLib4Pascal is a Delphi/FreePascal port of Fast-QR-Code-generator by Nayuki, providing an easy-to-use interface for generating QR Codes, released under the permissive MIT License.

Table of Contents

Features

  • All QR versions and error correction levels -- supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard
  • Multiple output formats -- raw modules/pixels, SVG XML string/file, ImageObject (bmp, jpg, png) for VCL and LCL
  • Efficient encoding -- numeric and special-alphanumeric text encoded in less space than general text
  • Customizable colors -- configurable background and foreground colors for generated QR codes
  • Fine-grained control -- specify version range, mask pattern, error correction level, or let the library choose optimal values automatically
  • ECI segments -- manually create data segment lists and add ECI segments
  • Cross-framework -- FCL, VCL (Delphi), LCL (Lazarus), and experimental FMX support

Getting Started

Prerequisites

Compiler Minimum Version
Delphi XE3 or later
FreePascal 3.0.0 or later

Supported Frameworks

Framework Notes
FCL FreePascal
VCL Delphi
LCL Lazarus
FMX Experimental -- enable {.$DEFINE Framework_FMX} in QRCodeGenLib.inc

Installation

Method 1: Using Packages

Use the provided packages in the Packages folder.

Method 2: Search Path

Add the library path and its subdirectories to your project's search path.

Quick Examples

Generate a Simple QR Code (SVG)

uses
  SysUtils, QlpQRCodeGenLibTypes, QlpQRCode, QlpIQRCode;  

var
  LQR: IQRCode;
  LSVG: String;
begin
  LQR := TQRCode.EncodeText('Hello QRCodeGenLib4Pascal',
    TQrCode.TEcc.eccLow, TEncoding.UTF8);
  LSVG := LQR.ToSVGString(4);

  WriteLn(LSVG);   
end;

Generate a QR Code with Custom Colors (BMP -- VCL/LCL)

uses
  SysUtils, Graphics, QlpQRCodeGenLibTypes, QlpQRCode, QlpIQrCode;  

var
  LQR: IQRCode;
  LBmp: TQRCodeGenLibBitmap;
begin
  LQR := TQRCode.EncodeText('Custom colors!',
    TQRCode.TEcc.eccMedium, TEncoding.UTF8);

  LBmp := LQR.ToBitmapImage(10, 4); 
  try
    LBmp.SaveToFile('qrcode.bmp');
  finally
    LBmp.Free;
  end; 
end;

Advanced: Manual Segment with Version Range

uses
  SysUtils, QlpQRCodeGenLibTypes, QlpQRCode, QlpIQRCode, QlpQRSegment, QlpIQRSegment; 

var
  LSegments: TArray<IQrSegment>;
  LQR: IQRCode;  
begin
  LSegments := TQRSegment.MakeSegments('0123456789', TEncoding.UTF8);

  LQR := TQRCode.EncodeSegments(LSegments,
    TQRCode.TEcc.eccHigh,
    5,   // minimum version
    10,  // maximum version
    -1,  // auto mask
    True // boost ECC
  );

  WriteLn(LQR.ToSVGString(4));
end;

Running Demos

Check out the QRCodeGenLib.Demo folder for complete working examples.

Contributing

Contributions are welcome. Please open an issue for bug reports or feature requests, and submit pull requests.

Tip Jar

If you find this library useful and would like to support its continued development, tips are greatly appreciated! 🙏

Cryptocurrency Wallet Address
Bitcoin Bitcoin (BTC) bc1quqhe342vw4ml909g334w9ygade64szqupqulmu
Ethereum Ethereum (ETH) 0x53651185b7467c27facab542da5868bfebe2bb69
Solana Solana (SOL) BPZHjY1eYCdQjLecumvrTJRi5TXj3Yz1vAWcmyEB9Miu

License

QRCodeGenLib4Pascal is released under the MIT License.

About

Generates QR Codes from text strings and byte arrays.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors

Languages