免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3572 | 回复: 0
打印 上一主题 下一主题

如何把的delphi 转换正C,GUI,多谢 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-23 15:41 |只看该作者 |倒序浏览
3可用积分
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;

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP