source: trunk/Packages/lazbarcodes/src/lbc_basic.pas

Last change on this file was 123, checked in by chronos, 3 years ago
  • Added: QR code image visible in contact others tab. It can be saved as image to file.
File size: 2.5 KB
Line 
1unit lbc_basic;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils,
9 zint, lbc_helper;
10
11function ZBarcode_Create(): PointerTo_zint_symbol;
12procedure ZBarcode_Clear(symbol: PointerTo_zint_symbol);
13procedure ZBarcode_Delete(symbol: PointerTo_zint_symbol);
14
15implementation
16
17function ZBarcode_Create(): PointerTo_zint_symbol;
18var
19 symbol: PointerTo_zint_symbol;
20 i: Integer;
21begin
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);
56end;
57
58procedure ZBarcode_Clear(symbol: PointerTo_zint_symbol);
59var
60 j: Integer;
61 i: Integer;
62begin
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;
85end;
86
87procedure ZBarcode_Delete(symbol: PointerTo_zint_symbol);
88var
89 l: PointerTo_zint_render_line;
90 line: PointerTo_zint_render_line;
91 s: PointerTo_zint_render_string;
92 TheString: PointerTo_zint_render_string;
93begin
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);
118end;
119
120end.
121
Note: See TracBrowser for help on using the repository browser.