Home > Back-end >  Delphi7 under the qr code is generated
Delphi7 under the qr code is generated

Time:11-09

Under Delphi7 generated qr code, online, etc

CodePudding user response:

Although D not fire now, but this information is good search...

CodePudding user response:

A control ZXingQRCode
The Form file:
 
The object Form1: TForm1
Left=306
Top=148
BorderStyle=bsDialog
Caption='Form1'
ClientHeight=300
ClientWidth=570
Color=clBtnFace
The Font. The Charset=DEFAULT_CHARSET
The Font, Color=clWindowText
The Font, Height=11
Sans Serif Font. The Name='MS'
The Font, Style=[]
OldCreateOrder=False
OnCreate=FormCreate
OnDestroy=FormDestroy
PixelsPerInch=96
TextHeight=13
The object Label1: TLabel
Left=8
Top=13
Width=21
Height=13
Caption='Text'
End
The object Label2: TLabel
Left=8
Top=69
Width=45
Height=13
Caption='Encoding'
End
The object Label3: TLabel
Left=184
Top=69
Width=51
Height=13
Caption='Quiet zone'
End
The object Label4: TLabel
Left=296
Top=13
Width=38
Height=13
Caption='Preview'
End
The object PaintBox1: TPaintBox
Left=296
Top=30
Width=242
Height=242
PopupMenu=PopupMenu1
OnPaint=PaintBox1Paint
End
The object Image1: TImage
Left=296
Top=30
Width=256
Height=256
PopupMenu=PopupMenu1
Transparent=True
End
The object edtText: TEdit
Left=8
Top=32
Width=265
Height=21
TabOrder=0
Text='Hello world'
OnChange=edtTextChange
End
The object cmbEncoding: TComboBox
Left=8
Top=88
Width=145
Height=21
Style=csDropDownList
ItemHeight=13
ItemIndex=0
TabOrder=1
Text='Auto'
OnChange=edtTextChange
The Items. Strings=(
'Auto'
'Numeric'
'Alphanumeric'
'the ISO - 8859-1
'utf-8 without BOM'
'utf-8 with BOM)
End
The object edtQuietZone: TEdit
Left=184
Top=88
Width=89
Height=21
TabOrder=2
Text='1'
OnChange=edtTextChange
End
The object PopupMenu1: TPopupMenu
Left=208
Top=144
The object N1: TMenuItem
Caption='save the qr code'
The OnClick=N1Click
End
End
The object SavePictureDialog1: TSavePictureDialog
Left=256
Top=200
End
End

CodePudding user response:

Code files:
 
The unit Unit1;

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DelphiZXingQRCode StdCtrls ExtCtrls, Menus, ExtDlgs;

Type
TForm1=class (TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
EdtText: TEdit;
CmbEncoding: TComboBox;
EdtQuietZone: TEdit;
Label4: TLabel;
PaintBox1: TPaintBox;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
SavePictureDialog1: TSavePictureDialog;
Image1: TImage;
Procedure FormCreate (Sender: TObject);
Procedure FormDestroy (Sender: TObject);
Procedure PaintBox1Paint (Sender: TObject);
Procedure edtTextChange (Sender: TObject);
Procedure N1Click (Sender: TObject);
Private
QRCodeBitmap: TBitmap;
Procedure UpdateQRCode;
Public
end;

Var
Form1: TForm1;

Implementation

{$R *. DFM}

Procedure TForm1. FormCreate (Sender: TObject);
The begin
QRCodeBitmap:=TBitmap. Create;
UpdateQRCode;
end;

Procedure TForm1. FormDestroy (Sender: TObject);
The begin
QRCodeBitmap. Free;
end;


Procedure TForm1. UpdateQRCode;
Var
QRCode: TDelphiZXingQRCode;
The Row, Col: Integer;
The begin
QRCode:=TDelphiZXingQRCode. Create;
Try
QRCode. Data:=Trim (edtText. Text);
QRCode. Encoding:=TQRCodeEncoding (cmbEncoding ItemIndex);
QRCode. QuietZone:=StrToIntDef (Trim (edtQuietZone. Text), 4);
QRCodeBitmap. Height:=QRCode. Rows;
QRCodeBitmap. Width:=QRCode. Columns;

For Row:=0 to QRCodeBitmap. Do Height - 1
The begin
For Col:=0 to QRCodeBitmap. Do Width - 1
The begin
If (QRCode. IsBlack [Row, Col]) then
The begin
QRCodeBitmap. Canvas. Pixels [Col, Row] :=clBlack;
End the else
The begin
QRCodeBitmap. Canvas. Pixels [Col, Row] :=clWhite;
end;
end;
end;
The finally
QRCode. Free;
end;
Image1. Stretch:=True;
Image1. Picture. Bitmap:=QRCodeBitmap;
//PaintBox1. Repaint;
end;

Procedure TForm1. PaintBox1Paint (Sender: TObject);
//var
//Scale: Double;
The begin
//PaintBox1. Canvas. Brush. Color:=clWhite;
//PaintBox1. Canvas. FillRect (the Rect (0, 0, PaintBox1 Width, PaintBox1, Height));
//if ((QRCodeBitmap Width & gt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related