如何把的delphi 转换正C,GUI,多谢
function PrnBar_Ean13(left,top,width,height:integer;bhuman:Boolean;barcode:string;var bmp1:TBitmap):integer;
const
// 商品条码字符集
// 左侧数据符,A子集,奇数位
lodd:array[0..9] of string[7]=('0001101','0011001','0010011','0111101','0100011','0110001','0101111','0111011','0110111','0001011');
// 左侧数据符,B子集,偶数位
leven:array[0..9] of string[7]=('0100111','0110011','0011011','0100001','0011101','0111001','0000101','0010001','0001001','0010111');
// 右侧数据符&校验符,C子集,偶数位
reven:array[0..9] of string[7]=('1110010','1100110','1101100','1000010','1011100','1001110','1010000','1000100','1001000','1110100');
// 前置码,左侧数据符的选择规则 (1:A子集 2:B子集)
Hide:array[0..9] of string[6]=('111111','110100','110010','110001','101100','100110','100011','101010','101001','100101');
var i:integer;
aC:TCanvas;
// bmp:TBitmap;
bmpW,bmpH:integer;
rect:TRect;
X,Y:integer;
procedure line(sx,sy,tx,ty:integer);
begin
aC.MoveTo(sx,sy);
aC.LineTo(tx,ty);
end;
function drawunit(x,y,w,h:integer;ss,dig:string;bhuman:Boolean):integer;
var ii:integer;
begin
aC.Pen.Width:=w;
if bHuman then
aC.TextOut(x,y+h+5,dig)
else
aC.TextOut(x-6,y+h-5,dig);
for ii:=0 to length(ss)-1
do begin
if ss[ii+1]='1' then
aC.Pen.Color:=ClBlack
else aC.Pen.Color:=ClWhite;
line(x+ii*w,y,x+ii*w,y+h);
end;
result:=length(ss)*w;
end;
begin
barcode:=toEan13(barcode);
bmp1.Width:=200; //以前是200
bmp1.Height:=50; //50
aC:=bmp1.Canvas;
width:=1;
height:=15;
left:=left+drawunit(left,top,width,height+iif(bhuman,10,0),'101',copy(barcode,1,1),false);
for i:=2 to 7 do
begin
if hide[strtoint(barcode[1])][i-1]='1' then
begin
left:=left+drawunit(left,top,width,height,lodd[strtoint(barcode)],barcode,bhuman);
end
else
begin
left:=left+drawunit(left,top,width,height,leven[strtoint(barcode)],barcode,bhuman);
end;
end;
left:=left+drawunit(left,top,width,height+iif(bhuman,10,0),'01010','',False);
for i:=8 to 13 do
begin
left:=left+drawunit(left,top,width,height,reven[strtoint(barcode)],barcode,bhuman);
end;
drawunit(left,top,width,height+iif(bhuman,10,0),'101','',False);
result:=1;
// bmp.Free;
// ac.Free;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论