1 | unit lbc_basic;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils,
|
---|
9 | zint, lbc_helper;
|
---|
10 |
|
---|
11 | function ZBarcode_Create(): PointerTo_zint_symbol;
|
---|
12 | procedure ZBarcode_Clear(symbol: PointerTo_zint_symbol);
|
---|
13 | procedure ZBarcode_Delete(symbol: PointerTo_zint_symbol);
|
---|
14 |
|
---|
15 | implementation
|
---|
16 |
|
---|
17 | function ZBarcode_Create(): PointerTo_zint_symbol;
|
---|
18 | var
|
---|
19 | symbol: PointerTo_zint_symbol;
|
---|
20 | i: Integer;
|
---|
21 | begin
|
---|
22 | symbol := GetMem (SizeOf (zint_symbol));
|
---|
23 | if not Assigned(symbol) then
|
---|
24 | begin
|
---|
25 | exit (nil);
|
---|
26 | end;
|
---|
27 | FillByte(symbol^, SizeOf (zint_symbol),0);
|
---|
28 | symbol^.symbology := BARCODE_CODE128;
|
---|
29 | symbol^.height := 0;
|
---|
30 | symbol^.whitespace_width := 0;
|
---|
31 | symbol^.border_width := 0;
|
---|
32 | symbol^.output_options := 0;
|
---|
33 | symbol^.rows := 0;
|
---|
34 | symbol^.width := 0;
|
---|
35 | strcpy (symbol^.fgcolour, '000000');
|
---|
36 | strcpy (symbol^.bgcolour, 'ffffff');
|
---|
37 | strcpy (symbol^.outfile, '');
|
---|
38 | symbol^.scale := 1.0;
|
---|
39 | symbol^.option_1 := -1;
|
---|
40 | symbol^.option_2 := 0;
|
---|
41 | symbol^.option_3 := 928;
|
---|
42 | symbol^.show_hrt := 1;
|
---|
43 | symbol^.input_mode := DATA_MODE;
|
---|
44 | strcpy (symbol^.primary, '');
|
---|
45 | FillByte(symbol^.encoded_data, SizeOf(symbol^.encoded_data), 0);
|
---|
46 | i := 0;
|
---|
47 | while i < 178 do
|
---|
48 | begin
|
---|
49 | symbol^.row_height[i] := 0;
|
---|
50 | Inc (i);
|
---|
51 | end;
|
---|
52 | symbol^.bitmap := nil;
|
---|
53 | symbol^.bitmap_width := 0;
|
---|
54 | symbol^.bitmap_height := 0;
|
---|
55 | exit (symbol);
|
---|
56 | end;
|
---|
57 |
|
---|
58 | procedure ZBarcode_Clear(symbol: PointerTo_zint_symbol);
|
---|
59 | var
|
---|
60 | j: Integer;
|
---|
61 | i: Integer;
|
---|
62 | begin
|
---|
63 | i := 0;
|
---|
64 | while i < symbol^.rows do
|
---|
65 | begin
|
---|
66 | j := 0;
|
---|
67 | while j < symbol^.width do
|
---|
68 | begin
|
---|
69 | unset_module (symbol, i, j);
|
---|
70 | Inc (j);
|
---|
71 | end;
|
---|
72 | Inc (i);
|
---|
73 | end;
|
---|
74 | symbol^.rows := 0;
|
---|
75 | symbol^.width := 0;
|
---|
76 | symbol^.text[0] := 0;
|
---|
77 | symbol^.errtxt[0] := #0;
|
---|
78 | if Assigned(symbol^.bitmap) then
|
---|
79 | begin
|
---|
80 | FreeMem (symbol^.bitmap);
|
---|
81 | end;
|
---|
82 | symbol^.bitmap := nil;
|
---|
83 | symbol^.bitmap_width := 0;
|
---|
84 | symbol^.bitmap_height := 0;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | procedure ZBarcode_Delete(symbol: PointerTo_zint_symbol);
|
---|
88 | var
|
---|
89 | l: PointerTo_zint_render_line;
|
---|
90 | line: PointerTo_zint_render_line;
|
---|
91 | s: PointerTo_zint_render_string;
|
---|
92 | TheString: PointerTo_zint_render_string;
|
---|
93 | begin
|
---|
94 | if Boolean(symbol^.bitmap <> nil) then
|
---|
95 | begin
|
---|
96 | FreeMem (symbol^.bitmap);
|
---|
97 | end;
|
---|
98 | if Boolean(symbol^.rendered <> nil) then
|
---|
99 | begin
|
---|
100 | line := symbol^.rendered^.lines;
|
---|
101 | while Assigned(line) do
|
---|
102 | begin
|
---|
103 | l := line;
|
---|
104 | line := line^.next;
|
---|
105 | FreeMem (l);
|
---|
106 | end;
|
---|
107 | TheString := symbol^.rendered^.strings;
|
---|
108 | while Assigned(TheString) do
|
---|
109 | begin
|
---|
110 | s := TheString;
|
---|
111 | TheString := TheString^.next;
|
---|
112 | FreeMem (s^.text);
|
---|
113 | FreeMem (s);
|
---|
114 | end;
|
---|
115 | FreeMem (symbol^.rendered);
|
---|
116 | end;
|
---|
117 | FreeMem (symbol);
|
---|
118 | end;
|
---|
119 |
|
---|
120 | end.
|
---|
121 |
|
---|