Download the latest zint.dll (v2.11) from here https://sourceforge.net/projects/zint/
I'm only using ZBarcode_Encode_and_Buffer. If you need to use other function, please adjust the zint.pas accordingly.
Sample code as below:
procedure ZBarcode_To_Bitmap(symbol: PZint_Symbol; const ABitmap: TBitmap);
var
SrcRGB: PRGBTriple;
Row, RowWidth: Integer;
begin
ABitmap.PixelFormat := pf24bit;
ABitmap.SetSize(symbol.bitmap_width, symbol.bitmap_height);
SrcRGB := Pointer(symbol.bitmap);
RowWidth := symbol.bitmap_width * 3;
for Row := 0 to symbol.bitmap_height - 1 do
begin
CopyMemory(ABitmap.ScanLine[Row], SrcRGB, RowWidth);
Inc(SrcRGB, symbol.bitmap_width);
end;
SetBitmapBits(ABitmap.Handle, symbol.bitmap_width * symbol.bitmap_height * 3, symbol.bitmap);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
lvSymbol : Pzint_symbol;
lvErrorNumber: Integer;
lvData: UTF8String;
lvBitMap: TBitmap;
lvErrorText: string;
begin
lvSymbol := ZBarcode_Create();
if lvSymbol = nil then
Exit;
lvBitMap := TBitmap.Create;
try
lvSymbol.symbology:= BARCODE_QRCODE;
lvSymbol.input_mode := DATA_MODE ;
lvData := utf8string(Edit1.Text);
lvErrorNumber := ZBarcode_Encode_and_Buffer(lvSymbol, PAnsiChar(lvData), Length(lvData), 0);
if lvErrorNumber = 0 then
begin
ZBarcode_To_Bitmap(lvSymbol, lvBitMap);
ZBarcode_Print(lvSymbol,0) ;
Image1.Picture.Bitmap.Width := Image1.Width;
Image1.Picture.Bitmap.Height := Image1.Height;
Image1.Picture.Bitmap.Canvas.Brush.Color := clWhite;
Image1.Picture.Bitmap.Canvas.FillRect(Rect(0, 0, Image1.Width, Image1.Height));
Image1.Picture.Bitmap.Canvas.StretchDraw(Rect(10, 10, Image1.Width - 10, Image1.Height - 10), lvBitMap);
end
else
begin
Image1.Picture.Bitmap.Width := Image1.Width;
Image1.Picture.Bitmap.Height := Image1.Height;
Image1.Picture.Bitmap.Canvas.Brush.Color := clWhite;
Image1.Picture.Bitmap.Canvas.FillRect(Rect(0, 0, Image1.Width, Image1.Height));
lvErrorText := String(AnsiString(lvSymbol.errtxt));
ShowMessage('barcode error:' + lvErrorText);
end;
finally
lvBitMap.Free;
lvBitMap := nil;
ZBarcode_Delete(lvSymbol);
end;
end;
zint.pas