procedure TForm1.Button1Click(Sender: TObject);
var
 FSymbol: PZSymbol;
 s: string;
begin
    Image1.Picture.Bitmap := nil;
    s := Memo1.Text;
    FSymbol := ZBarcode_Create;
    try
     FSymbol.symbology := 58;
     ZBarcode_Encode_and_Buffer(FSymbol, PChar(s), Length(s), 0);
     ZBarcodeToBitmap(FSymbol, Image1.Picture.Bitmap);
     finally
      ZBarcode_Delete(FSymbol);
      FSymbol := nil;
   end;
有这样一一段代码,这段是,把FSymbol用image1显示出图片来。
我想不不显示出来,直接生成一个BMP的文件到D:\111.BMP
如果修改语句,谢谢

解决方案 »

  1.   

    显示不显示你改一下image1的visible属性就可以了。
    至于保存文件,直接调用self.Image1.Picture.SaveToFile('D:\111.BMP');
    当然也可以不用image,改用变量也可以。主要看你ZBarcodeToBitmap这个函数是否支持变量。
      

  2.   

    ZBarcodeToBitmap直接生成TBitmap对象,然后TBitmap.SaveToFile
      

  3.   

    ZBarcodeToBitmap 是这么定义的,我就是不想用image,想用变量直接生成图片文件
    procedure ZBarcodeToBitmap(ASymbol: PZSymbol; const ABitmap: TBitmap);
    var
       myp: PRGBTriple;
       row: Integer;
       rowwidth: Integer;
       begin
        ABitmap.PixelFormat := pf24bit;
        ABitmap.Width := ASymbol.bitmap_width;
        ABitmap.Height := ASymbol.bitmap_height;
        myp := Pointer(ASymbol.bitmap);
        rowwidth := Asymbol.bitmap_width * 3;
         for row := 0 to ASymbol.bitmap_height - 1 do
         begin
         CopyMemory(ABitmap.ScanLine[row], myp, rowwidth);
         Inc(myp, Asymbol.bitmap_width);
         end;   end;
      

  4.   

    以下代码没有测试,楼主试一下
    procedure TForm1.Button1Click(Sender: TObject);
    var
     FSymbol: PZSymbol;
     s: string;
     Bitmap: TBitmap;
    begin
      Bitmap := nil;
      Bitmap := TBitmap.Create;
      s := Memo1.Text;
      FSymbol := ZBarcode_Create;
      try
      FSymbol.symbology := 58;
      ZBarcode_Encode_and_Buffer(FSymbol, PChar(s), Length(s), 0);
      ZBarcodeToBitmap(FSymbol, Bitmap);
      Bitmap.SaveToFile('D:\111.bmp');
      finally
      ZBarcode_Delete(FSymbol);
      FSymbol := nil;
      FreeAndNil(Bitmap);
      end;
      

  5.   

    找到资料,这个学会使用了,还是非常感谢你 babydog01