/*Title:Delphi,VC++,VB,C#等實現二維條碼繪制
*Author:Insun
*Blog:http://yxmhero1989.blog.163.com
*From:www.4safer.com
*/
其他參見我的:關於二維碼(About 2D Barcode) http://yxmhero1989.blog.163.com/blog/static/11215795620110172842999/
由於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.wikipedia.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;
如圖所示:
VC++,VB,C#一筆帶過,自己看References 源碼 QRcodeDecoder.rar VC++6.0寫的- -囧 VB MakeTwoBarCode: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