当前位置:编程学习 > VB >>

Delphi,VC++,VB,C#等实现二维条码绘制

/*Title:Delphi,VC++,VB,C#等实现二维条码绘制

*Author:Insun

*Blog:http://yxmhero1989.blog.163.com

*From:www.4safer.com

*/

先认识几个基本概念:

PDF417  ----条形码
2D BarCode ---二维码- --  QRCode  ---Quick Response Code 二维空间码
DataMatrix  -- 数据矩阵

 其他参见我的:关于二维码(About 2D Barcode) http://yxmhero1989.blog.163.com/blog/static/11215795620110172842999/

Data Matrix 二维条码的发展 http://www.systron.com.cn/datamatrix.htm

ECC200原始出处是 DataMatrix,官方网址在http://www.neodynamic.com/barcodes/DataMatrix_Barcode.aspx

先说Delphi实现二维条码绘制,需要用到ECC200.pas和ReedSolomon.pas

uses ECC200,ReedSolomon;

否则肯定找不到ReedSolomon.dcu 和ECC200.dcu啦。
[Fatal Error] ECC200.pas(569): File not found: ReedSolomon.dcu

由于pudn上有个源码

《delphi实现的二 维 码 生成 控制代 码-delphi realize two-dimensional code generated control code》

ECC200.pas:http://read.pudn.com/downloads111/sourcecode/delphi_control/460570/Delphi/ECC200.pas__.htm

ReedSolomon.pas:http://read.pudn.com/downloads111/sourcecode/delphi_control/460570/Delphi/ReedSolomon.pas__.htm

Reed–Solomon error correction 关于Reed–Solomon纠错码 可以看:http://en.易做图.org/wiki/Reed%E2%80%93Solomon_error_correction

关于reed-solomon codes 老外有篇算易做图文:
http://ptgmedia.pearsoncmg.com/images/art_sklar7_reed-solomon/elementLinks/art_sklar7_reed-solomon.pdf

 

      procedure Generate2DCode(AStr: string; ASize: Integer; ABmp: TBitmap);
var
s : TByteArray;
m : TByteArray;
i, j: Integer;
w, h : integer;
cc: Integer;
begin
if not Assigned(ABmp) then
Exit;
SetLength(s, Length(AStr));
for i := 1 to Length(AStr) do
begin
s[i-1] := Ord(AStr[i]);
end;
 CalcECC200(s, ecc200_Autosize, ecc200_Square, m, w, h); // ECC200.pas 
ABmp.Width := w * ASize;
ABmp.Height := h * ASize;
for i := 0 to h - 1 do
begin
for j := 0 to w - 1 do
begin
cc := m[i * w + j];
if cc = 1 then
begin
ABmp.Canvas.Brush.Color := clBlack;
ABmp.Canvas.Rectangle(Rect(
j*ASize,
i*ASize,
j*ASize+ASize,
i*ASize+ASize));
end;
end;
end;
end;

调用很简单:

    procedure TForm1.FormCreate(Sender: TObject);
var
bmp: TBitmap;
begin
bmp:=TBitmap.Create;
  // 第二个参数表示每个小格的边长
Generate2DCode(Insun祝您新年快乐  Blog:http://yxmhero1989.blog.163.com , 2, bmp);
  // TODO: your code here
     //bmp.SaveToFile(1.bmp);
     Image1.Picture.Assign(bmp);
bmp.Free;
end;  

如图所示:

Delphi,VC++,VB,C等实现二维条码绘制 - InSun - Minghacker is Insun
VC++,VB,C#一笔带过,自己看References 源码
 
QRcodeDecoder.rar  VC++6.0写的- -囧
Delphi,VC++,VB,C等实现二维条码绘制 - InSun - Minghacker is Insun
 
 VB MakeTwoBarCode:
 
 
Delphi,VC++,VB,C等实现二维条码绘制 - InSun - Minghacker is Insun
 
 

 References:

1。使用ECC200绘制二维码

http://hi.baidu.com/rarnu/blog/item/373ead772ee40010b151b9d1.html

2.。VB MakeTwoBarCode.rar (125.79 kB) 源代码下载
http://www.hackchina.com/dlpre.php?id=194965

3。C# 实现QRCode
http://www.pudn.com/downloads136/sourcecode/windows/csharp/detail581330.html

http://www.7880.com/download/ewbm-22338.html

4。QRcodeDecoder.rar  VC++
http://www.hackchina.com/cont/76458
5.。利用QRmaker制作二维码
http://windyli.blog.51cto.com/1300305/284574

6
http://www.barcommune.com/Pdf417.html
7。Java解析与生成二维码的源码下载
http://download.csdn.net/source/2580954

补充:软件开发 , Delphi ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,