Code Monkey home page Code Monkey logo

delphizxingqrcodeex's Introduction

DelphiZXingQRCodeEx

DelphiZXingQRCodeEx is a Delphi port of the QR Code functionality from ZXing, an open source barcode image processing library.

The code was initially ported to Delphi by Senior Debenu Developer, Kevin Newman (project DelphiZXingQRCode, see links below). Then it was changed by Michael Demidov. The changes are listed in CHANGELOG.md.

The most fundamental differences are:

  1. Error correction level has been fixed.
  2. Support for programmer-defined charsets. As an example, I implemented Win-1251 Russian charset and URL encoding (when non-Latin characters are represented as %-codes).
  3. Exception handling has been added. There is no more Access Violation when input string is too long.
  4. New QRGraphics.pas unit has been added that contains several functions to draw the QR Code on a given canvas (TCanvas) and to generate either a bitmap or a metafile.
  5. Still compatible with older versions of Delphi (at least Delphi 6). Compatible with Lazarus (1.2.6, for Windows), see CHANGELOG.md (section 5).

The port retains the original Apache License (v2.0).

This fork's changes in regards to MichaelDemidov/DelphiZXingQRCodeEx

Made this control ready for banking type applications, which require forced version 15 QR codes with optional ECI record

  1. Added property "Version" which when set gives an ability to force a version instead of autimatically finding the smallest one. This is needed for example by banking applications as they require the version to be 15.
  2. Added property "ECI" which when set adds ECI record to the QR code (e.g. .ECI=4 for ISO-8859-2).
  3. Added support for ISO 8859-2 (Latin 2) character set (unit QR_ISO88592.pas) as encoding with index 8.

Links

  1. Original DelphiZXingQRCode project
  2. Debenu site
  3. GitHub Mirror
  4. ZXing
  5. Google Code
  6. GitHub
  7. Michael Demidov's blog (in Russian only, sorry)

Software Requirements

Delphi 6 or newer (I tested with Delphi 6 and XE3).

Getting Started

A sample Delphi project is provided in the TestApp folder to demonstrate how to use DelphiZXingQRCode.

And an example for a banking application would be:

var
  QRCode    : TDelphiZXingQRCode;
  QRBitmap  : tBitmap;
    
QRCode := TDelphiZXingQRCode.Create;
QRBitmap := tBitmap.Create;
try

  // QR ISO 18004 ver 15 (77x77 mandatory), byte data, ECC Level M, ISO 8859-2, ECI 000004, 32.6 x 32.6 mm
  QRCode.BeginUpdate;
  QRCode.Data := 'your data as required by your bank';
  QRCode.Version := 15;
  QRCode.ErrorCorrectionOrdinal := ecoM;
  QRCode.Encoding := ENCODING_ISO88592;
  QRCode.ECI := 4;  // 4 = ISO-8859-2
  QRCode.RegisterEncoder(ENCODING_ISO88592, TIso88592Encoder);
  QRCode.EndUpdate(TRUE);

  QRBitmap.Width := QRCode.Rows;
  QRBitmap.Height := QRCode.Columns;
  for x := 0 to QRCode.Rows - 1 do
    for y := 0 to QRCode.Columns - 1 do
      if QRCode.IsBlack[y, x] then
        QRBitmap.Canvas.Pixels[y, x] := clBlack
	  else
        QRBitmap.Canvas.Pixels[y, x] := clWhite;
	  
  // at this point QR code is in QRBitmap and you can display or print it as you like

finally
  FreeAndNil(QRCode);
  FreeAndNil(QRBitmap);
end;

delphizxingqrcodeex's People

Contributors

michaeldemidov avatar gregorb avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.