Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Delphi Examples of Datamatrix Encoder SDK/DLL

Delphi Examples of Datamatrix Encoder SDK/DLL 4 years 4 months ago #3882

LPDATAMATRIXCONTEXT = ^TDATAMATRIXCONTEXT;
TDATAMATRIXCONTEXT = record
code: array[1..3300] of char;
size : integer;
encoding : integer;
dotPixel : integer;
sizePattern : integer;
nMargin : integer;
clBackGround : TColor;
clForeGround : TColor;
end;

procedure InitWorkSpace(pDataMatrixCtx : LPDATAMATRIXCONTEXT ); stdcall; external 'DATAMATRIXENCODEDLL.DLL';
function DataMatrixEncode2File(pDataMatrixCtx : LPDATAMATRIXCONTEXT;lpImageFile :PChar) : boolean; stdcall;external 'DATAMATRIXENCODEDLL.DLL';
function DataMatrixEncode2Bitmap(pDataMatrixCtx : LPDATAMATRIXCONTEXT) : HBITMAP;stdcall;external 'DATAMATRIXENCODEDLL.DLL';
function FreeWorkSpace : boolean;stdcall external 'DATAMATRIXENCODEDLL.DLL';


procedure TForm1.Button1Click(Sender: TObject);
var
ctx : TDATAMATRIXCONTEXT;
s : string;
i : Integer;
bmp : HBITMAP;
img : TBitmap;
pCtx : LPDATAMATRIXCONTEXT;
begin
pCtx := @ctx;
InitWorkSpace(pCtx);
ctx.encoding := ComboBox1.ItemIndex;

ctx.nMargin := strtoInt(Edit1.Text);
ctx.sizePattern := strtoInt(Edit3.Text);
ctx.dotPixel := strtoInt(Edit2.Text);
ctx.clBackGround := $00FFFFFF;//ColorBox1.color and $00FFFFFF;
ctx.clForeGround := 0;
if (Edit5.Text <> '') then StrMove(@Ctx.code,PChar(Edit5.Text),Length(Edit5.Text));
ctx.size := Length(Edit5.Text);
image1.Picture.CleanupInstance;
img := TBitmap.Create;

bmp := DataMatrixEncode2Bitmap(pCtx);

img.Handle := bmp;
image1.Picture.Assign(img);
img.Free;
ShowMessage('Make DataMatrix barcode successfully');
FreeWorkSpace();
end;
The administrator has disabled public write access.

  • Posts:59
  • developer's Avatar
  • developer
  • Moderator
  • OFFLINE
  • Karma: 1
  • Page:
  • 1
Time to create page: 0.239 seconds
Powered by Kunena Forum :: Wibi