Delpi Xing QR Code Oluşturma
Uses kısmına DelphiZXIngQRCode eklenmeli ve DelphiZXIngQRCode.pas dosyası projeye dahil edilmeli
procedure TAnaF.QROlustur(QrData:String;);
var
QRCode: TDelphiZXingQRCode;
Row, Column: Integer;
Bitmap: TBitmap;
Source: TRect;
Dest: TRect;
Png: TPngImage;
begin
sleep(100);
QRCode := TDelphiZXingQRCode.Create;
try
QRCode.Data := QrData;
QRCode.Encoding := TQRCodeEncoding(5);
QRCode.QuietZone := StrToIntDef('4', 4);
QRCodeBitmap.SetSize(QRCode.Rows, QRCode.Columns);
for Row := 0 to QRCode.Rows - 1 do
begin
for Column := 0 to QRCode.Columns - 1 do
begin
if (QRCode.IsBlack[Row, Column]) then
begin
QRCodeBitmap.Canvas.Pixels[Column, Row] := clBlack;
end else
begin
QRCodeBitmap.Canvas.Pixels[Column, Row] := clWhite;
end;
end;
end;
finally
QRCode.Free;
end;
PaintBox1.Repaint;
Application.ProcessMessages;
sleep(100);
Application.ProcessMessages;
Bitmap := TBitmap.Create;
try
with Bitmap do
begin
Width := 170;
Height := 170;
Dest := Rect(0, 0, Width, Height);
end;
with PaintBox1 do
Source := Rect(0, 0, Width, Height);
Bitmap.Canvas.CopyRect(Dest, PaintBox1.Canvas, Source);
Png := TPngImage.Create;
Application.ProcessMessages;
Png.Assign(Bitmap);
Application.ProcessMessages;
png.SaveToFile(KayitEdilecekKlasorYolu+'dosyaadi.png');
Png.Free;
finally
Bitmap.Free;
Application.ProcessMessages;
end;
end;
Kullanımı
QROlustur('QrCode içine gelecek string data');