TTMSFNCWXQRCode
The TTMSFNCWXQRCode
is a component to generate and show highly customizable QR codes. It uses
the EasyQRCodeJS JavaScript library.
Creating QR codes
Creating a QR code is as simple as setting the TTMSFNCWXQRCode.Text
property either at
designtime or at runtime. The default error correction level is set to M, it can be changed via the
TTMSFNCWXQRCode.ErrorCorrectionLevel
property:
procedure TForm2.Button1Click(Sender: TObject);
begin
TMSFNCWXQRCode1.ErrorCorrectionLevel := eclH;
TMSFNCWXQRCode1.Text := 'text to be encoded';
end;
Retrieving QR codes
To retrieve the QR codes, implement the TTMSFNCWXQRCode.OnGetQRCode
event. Access to the
generated QR code is provided as a TTMSFNCBitmap
. Process the TTMSFNCBitmap
parameter as it
fits best:
procedure TForm1.TMSFNCWXQRCode1GetBarcode(Sender: TObject;
ABitmap: TTMSFNCBitmap);
begin
//Save into a file, for example:
ABitmap.SaveToFile('path_to\my_code.png');
end;
Customization
The TTMSFNCWXQRCode
component provides various properties to customize the final QR code. For
all the available properties please check the Options part of the EasyQRCodeJS library:
https://github.com/ushelp/EasyQRCodeJS#options
procedure TForm2.Button1Click(Sender: TObject);
begin
TMSFNCWXQRCode1.Text := 'my cusomized barcode';
TMSFNCWXQRCode1.Settings.ColorDark := gcDeepskyblue;
TMSFNCWXQRCode1.Settings.ColorLight := gcAzure;
TMSFNCWXQRCode1.Settings.TimingHorizonalColor := gcDeepskyblue;
TMSFNCWXQRCode1.Settings.TimingVerticalColor := gcDeepskyblue;
TMSFNCWXQRCode1.Settings.PositionColor.TopLeftOuterColor := gcDodgerblue;
TMSFNCWXQRCode1.Settings.PositionColor.TopLeftInnerColor := gcDodgerblue;
TMSFNCWXQRCode1.Settings.PositionColor.TopRightOuterColor :=
gcDodgerblue;
TMSFNCWXQRCode1.Settings.PositionColor.TopRightInnerColor :=
gcDodgerblue;
TMSFNCWXQRCode1.Settings.PositionColor.BottomRightOuterColor :=
gcDodgerblue;
TMSFNCWXQRCode1.Settings.PositionColor.BottomRightInnerColor :=
gcDodgerblue;
end;
