| 1 |
|
|---|
| 2 | unit zint;
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | {
|
|---|
| 6 | Automatically converted by H2Pas 1.0.0 from zint.h
|
|---|
| 7 | The following command line parameters were used:
|
|---|
| 8 | zint.h
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | {$IFDEF FPC}
|
|---|
| 12 | {$MODE objfpc}{$H+}
|
|---|
| 13 | {$MODESWITCH AdvancedRecords}
|
|---|
| 14 | //{$PACKRECORDS C}
|
|---|
| 15 | {$ENDIF}
|
|---|
| 16 |
|
|---|
| 17 | { zint.h - definitions for libzint
|
|---|
| 18 |
|
|---|
| 19 | libzint - the open source barcode library
|
|---|
| 20 | Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
|
|---|
| 21 |
|
|---|
| 22 | Redistribution and use in source and binary forms, with or without
|
|---|
| 23 | modification, are permitted provided that the following conditions
|
|---|
| 24 | are met:
|
|---|
| 25 |
|
|---|
| 26 | 1. Redistributions of source code must retain the above copyright
|
|---|
| 27 | notice, this list of conditions and the following disclaimer.
|
|---|
| 28 | 2. Redistributions in binary form must reproduce the above copyright
|
|---|
| 29 | notice, this list of conditions and the following disclaimer in the
|
|---|
| 30 | documentation and/or other materials provided with the distribution.
|
|---|
| 31 | 3. Neither the name of the project nor the names of its contributors
|
|---|
| 32 | may be used to endorse or promote products derived from this software
|
|---|
| 33 | without specific prior written permission.
|
|---|
| 34 |
|
|---|
| 35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|---|
| 36 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|---|
| 37 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|---|
| 38 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|---|
| 39 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|---|
| 40 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|---|
| 41 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|---|
| 42 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|---|
| 43 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|---|
| 44 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|---|
| 45 | SUCH DAMAGE.
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | type
|
|---|
| 49 | { Pointer to line }
|
|---|
| 50 | PointerTo_zint_render_line=^zint_render_line;
|
|---|
| 51 | PointerTo_PointerTo_zint_render_line=^PointerTo_zint_render_line;
|
|---|
| 52 | zint_render_line = record
|
|---|
| 53 | x : single;
|
|---|
| 54 | y : single;
|
|---|
| 55 | length : single;
|
|---|
| 56 | width : single;
|
|---|
| 57 | next : PointerTo_zint_render_line; // Pointer to next line;
|
|---|
| 58 | end;
|
|---|
| 59 | PZintRenderLine = ^zint_render_line;
|
|---|
| 60 | PPZintRenderLine = ^PZintRenderLine;
|
|---|
| 61 |
|
|---|
| 62 | { Suggested string width, may be 0 if none recommended }
|
|---|
| 63 | { Pointer to character }
|
|---|
| 64 | PointerTo_zint_render_string=^zint_render_string;
|
|---|
| 65 | PointerTo_PointerTo_zint_render_string=^PointerTo_zint_render_string;
|
|---|
| 66 | zint_render_string = record
|
|---|
| 67 | x : single;
|
|---|
| 68 | y : single;
|
|---|
| 69 | fsize : single;
|
|---|
| 70 | width : single; // Suggested string width, may be 0 if none recommended
|
|---|
| 71 | length : longint;
|
|---|
| 72 | text : ^byte;
|
|---|
| 73 | next : PointerTo_zint_render_string; // Pointer to next character
|
|---|
| 74 | end;
|
|---|
| 75 | PZintRenderString = ^zint_render_string;
|
|---|
| 76 | PPZintRenderString = ^PZintRenderString;
|
|---|
| 77 |
|
|---|
| 78 | { Pointer to ring }
|
|---|
| 79 | PointerTo_zint_render_ring=^zint_render_ring;
|
|---|
| 80 | PointerTo_PointerTo_zint_render_ring=^PointerTo_zint_render_ring;
|
|---|
| 81 | zint_render_ring = record
|
|---|
| 82 | x : single;
|
|---|
| 83 | y : single;
|
|---|
| 84 | radius : single;
|
|---|
| 85 | line_width : single;
|
|---|
| 86 | next : PointerTo_zint_render_ring; // Pointer to next ring
|
|---|
| 87 | end;
|
|---|
| 88 |
|
|---|
| 89 | { Pointer to hexagon }
|
|---|
| 90 | PointerTo_zint_render_hexagon=^zint_render_hexagon;
|
|---|
| 91 | PointerTo_PointerTo_zint_render_hexagon=^PointerTo_zint_render_hexagon;
|
|---|
| 92 | zint_render_hexagon = record
|
|---|
| 93 | x : single;
|
|---|
| 94 | y : single;
|
|---|
| 95 | next : PointerTo_zint_render_hexagon; // ^Pointer to next hexagon;
|
|---|
| 96 | end;
|
|---|
| 97 |
|
|---|
| 98 | PointerTo_zint_render=^zint_render;
|
|---|
| 99 | zint_render = record
|
|---|
| 100 | width : single;
|
|---|
| 101 | height : single;
|
|---|
| 102 | lines : ^zint_render_line; // Pointer to first line
|
|---|
| 103 | strings : ^zint_render_string; // Pointer to first string
|
|---|
| 104 | rings : ^zint_render_ring; // Pointer to first ring
|
|---|
| 105 | hexagons : ^zint_render_hexagon; // Pointer to first hexagon
|
|---|
| 106 | // added by wp
|
|---|
| 107 | exact_width: single; // exact width of symbol after rendering. symbol^.width may be wrong...
|
|---|
| 108 | exact_height: single; // height of symbol after rendering.
|
|---|
| 109 | scale: single; // scale factor used for rendering
|
|---|
| 110 | end;
|
|---|
| 111 | PZintRender = ^zint_render;
|
|---|
| 112 |
|
|---|
| 113 | const
|
|---|
| 114 | ZINT_ROWS_MAX = 178;
|
|---|
| 115 | ZINT_COLS_MAX = 178;
|
|---|
| 116 | GL_CONST = 2.8346; // = 72 / 25.4 --> conversion pixels to mm
|
|---|
| 117 |
|
|---|
| 118 | type
|
|---|
| 119 | TColorChars = array[0..9] of char;
|
|---|
| 120 |
|
|---|
| 121 | PointerTo_zint_symbol = ^zint_symbol;
|
|---|
| 122 | zint_symbol = record
|
|---|
| 123 | symbology : longint;
|
|---|
| 124 | height : longint;
|
|---|
| 125 | whitespace_width : longint;
|
|---|
| 126 | border_width : longint;
|
|---|
| 127 | output_options : longint;
|
|---|
| 128 | fgcolour : TColorChars;
|
|---|
| 129 | bgcolour : TColorChars;
|
|---|
| 130 | outfile : array[0..255] of char;
|
|---|
| 131 | scale : single;
|
|---|
| 132 | option_1 : longint;
|
|---|
| 133 | option_2 : longint;
|
|---|
| 134 | option_3 : longint;
|
|---|
| 135 | option : longint; // added by wp
|
|---|
| 136 | show_hrt : longint;
|
|---|
| 137 | input_mode : longint;
|
|---|
| 138 | text : array[0..127] of byte;
|
|---|
| 139 | rows : longint;
|
|---|
| 140 | width : longint;
|
|---|
| 141 | primary : array[0..127] of char;
|
|---|
| 142 | encoded_data : array[0..ZINT_ROWS_MAX-1] of bitpacked array[0..ZINT_COLS_MAX-1] of boolean; // wp: changed to bitpacked
|
|---|
| 143 | row_height : array[0..ZINT_ROWS_MAX-1] of longint; // Largest symbol is 177x177 QR Code
|
|---|
| 144 | errtxt : array[0..99] of char;
|
|---|
| 145 | bitmap : ^char;
|
|---|
| 146 | bitmap_width : longint;
|
|---|
| 147 | bitmap_height : longint;
|
|---|
| 148 | rendered : ^zint_render;
|
|---|
| 149 | // added by wp
|
|---|
| 150 | font_height: integer;
|
|---|
| 151 | function GetText: String;
|
|---|
| 152 | procedure SetText(const AText: String);
|
|---|
| 153 | function GetErrorText: String;
|
|---|
| 154 | procedure SetErrorText(const AErrTxt: String);
|
|---|
| 155 | end;
|
|---|
| 156 | PZintSymbol = ^zint_symbol;
|
|---|
| 157 |
|
|---|
| 158 | TCharDynArray = array of char;
|
|---|
| 159 |
|
|---|
| 160 | const
|
|---|
| 161 | { Tbarcode 7 codes }
|
|---|
| 162 | BARCODE_CODE11 = 1;
|
|---|
| 163 | BARCODE_C25MATRIX = 2;
|
|---|
| 164 | BARCODE_C25INTER = 3;
|
|---|
| 165 | BARCODE_C25IATA = 4;
|
|---|
| 166 | BARCODE_C25LOGIC = 6;
|
|---|
| 167 | BARCODE_C25IND = 7;
|
|---|
| 168 | BARCODE_CODE39 = 8;
|
|---|
| 169 | BARCODE_EXCODE39 = 9;
|
|---|
| 170 | BARCODE_EANX = 13;
|
|---|
| 171 | BARCODE_EAN128 = 16;
|
|---|
| 172 | BARCODE_CODABAR = 18;
|
|---|
| 173 | BARCODE_CODE128 = 20;
|
|---|
| 174 | BARCODE_DPLEIT = 21;
|
|---|
| 175 | BARCODE_DPIDENT = 22;
|
|---|
| 176 | BARCODE_CODE16K = 23;
|
|---|
| 177 | BARCODE_CODE49 = 24;
|
|---|
| 178 | BARCODE_CODE93 = 25;
|
|---|
| 179 | BARCODE_FLAT = 28;
|
|---|
| 180 | BARCODE_RSS14 = 29;
|
|---|
| 181 | BARCODE_RSS_LTD = 30;
|
|---|
| 182 | BARCODE_RSS_EXP = 31;
|
|---|
| 183 | BARCODE_TELEPEN = 32;
|
|---|
| 184 | BARCODE_UPCA = 34;
|
|---|
| 185 | BARCODE_UPCE = 37;
|
|---|
| 186 | BARCODE_POSTNET = 40;
|
|---|
| 187 | BARCODE_MSI_PLESSEY = 47;
|
|---|
| 188 | BARCODE_FIM = 49;
|
|---|
| 189 | BARCODE_LOGMARS = 50;
|
|---|
| 190 | BARCODE_PHARMA = 51;
|
|---|
| 191 | BARCODE_PZN = 52;
|
|---|
| 192 | BARCODE_PHARMA_TWO = 53;
|
|---|
| 193 | BARCODE_PDF417 = 55;
|
|---|
| 194 | BARCODE_PDF417TRUNC = 56;
|
|---|
| 195 | BARCODE_MAXICODE = 57;
|
|---|
| 196 | BARCODE_QRCODE = 58;
|
|---|
| 197 | BARCODE_CODE128B = 60;
|
|---|
| 198 | BARCODE_AUSPOST = 63;
|
|---|
| 199 | BARCODE_AUSREPLY = 66;
|
|---|
| 200 | BARCODE_AUSROUTE = 67;
|
|---|
| 201 | BARCODE_AUSREDIRECT = 68;
|
|---|
| 202 | BARCODE_ISBNX = 69;
|
|---|
| 203 | BARCODE_RM4SCC = 70;
|
|---|
| 204 | BARCODE_DATAMATRIX = 71;
|
|---|
| 205 | BARCODE_EAN14 = 72;
|
|---|
| 206 | BARCODE_CODABLOCKF = 74;
|
|---|
| 207 | BARCODE_NVE18 = 75;
|
|---|
| 208 | BARCODE_JAPANPOST = 76;
|
|---|
| 209 | BARCODE_KOREAPOST = 77;
|
|---|
| 210 | BARCODE_RSS14STACK = 79;
|
|---|
| 211 | BARCODE_RSS14STACK_OMNI = 80;
|
|---|
| 212 | BARCODE_RSS_EXPSTACK = 81;
|
|---|
| 213 | BARCODE_PLANET = 82;
|
|---|
| 214 | BARCODE_MICROPDF417 = 84;
|
|---|
| 215 | BARCODE_ONECODE = 85;
|
|---|
| 216 | BARCODE_PLESSEY = 86;
|
|---|
| 217 |
|
|---|
| 218 | // Tbarcode 8 codes
|
|---|
| 219 | BARCODE_TELEPEN_NUM = 87;
|
|---|
| 220 | BARCODE_ITF14 = 89;
|
|---|
| 221 | BARCODE_KIX = 90;
|
|---|
| 222 | BARCODE_AZTEC = 92;
|
|---|
| 223 | BARCODE_DAFT = 93;
|
|---|
| 224 | BARCODE_MICROQR = 97;
|
|---|
| 225 |
|
|---|
| 226 | // Tbarcode 9 codes
|
|---|
| 227 | BARCODE_HIBC_128 = 98;
|
|---|
| 228 | BARCODE_HIBC_39 = 99;
|
|---|
| 229 | BARCODE_HIBC_DM = 102;
|
|---|
| 230 | BARCODE_HIBC_QR = 104;
|
|---|
| 231 | BARCODE_HIBC_PDF = 106;
|
|---|
| 232 | BARCODE_HIBC_MICPDF = 108;
|
|---|
| 233 | BARCODE_HIBC_BLOCKF = 110;
|
|---|
| 234 | BARCODE_HIBC_AZTEC = 112;
|
|---|
| 235 |
|
|---|
| 236 | // Zint specific
|
|---|
| 237 | BARCODE_AZRUNE = 128;
|
|---|
| 238 | BARCODE_CODE32 = 129;
|
|---|
| 239 | BARCODE_EANX_CC = 130;
|
|---|
| 240 | BARCODE_EAN128_CC = 131;
|
|---|
| 241 | BARCODE_RSS14_CC = 132;
|
|---|
| 242 | BARCODE_RSS_LTD_CC = 133;
|
|---|
| 243 | BARCODE_RSS_EXP_CC = 134;
|
|---|
| 244 | BARCODE_UPCA_CC = 135;
|
|---|
| 245 | BARCODE_UPCE_CC = 136;
|
|---|
| 246 | BARCODE_RSS14STACK_CC = 137;
|
|---|
| 247 | BARCODE_RSS14_OMNI_CC = 138;
|
|---|
| 248 | BARCODE_RSS_EXPSTACK_CC = 139;
|
|---|
| 249 | BARCODE_CHANNEL = 140;
|
|---|
| 250 | BARCODE_CODEONE = 141;
|
|---|
| 251 | BARCODE_GRIDMATRIX = 142;
|
|---|
| 252 |
|
|---|
| 253 | BARCODE_NO_ASCII = 1;
|
|---|
| 254 | BARCODE_BIND = 2;
|
|---|
| 255 | BARCODE_BOX = 4;
|
|---|
| 256 | BARCODE_STDOUT = 8;
|
|---|
| 257 | READER_INIT = 16;
|
|---|
| 258 | SMALL_TEXT = 32;
|
|---|
| 259 |
|
|---|
| 260 | DATA_MODE = 0;
|
|---|
| 261 | UNICODE_MODE = 1;
|
|---|
| 262 | GS1_MODE = 2;
|
|---|
| 263 | KANJI_MODE = 3;
|
|---|
| 264 | SJIS_MODE = 4;
|
|---|
| 265 |
|
|---|
| 266 | DM_SQUARE = 100;
|
|---|
| 267 |
|
|---|
| 268 | WARN_INVALID_OPTION = 2;
|
|---|
| 269 | ERROR_TOO_LONG = 5;
|
|---|
| 270 | ERROR_INVALID_DATA = 6;
|
|---|
| 271 | ERROR_INVALID_CHECK = 7;
|
|---|
| 272 | ERROR_INVALID_OPTION = 8;
|
|---|
| 273 | ERROR_ENCODING_PROBLEM = 9;
|
|---|
| 274 | ERROR_FILE_ACCESS = 10;
|
|---|
| 275 | ERROR_MEMORY = 11;
|
|---|
| 276 |
|
|---|
| 277 | implementation
|
|---|
| 278 |
|
|---|
| 279 | function zint_symbol.GetErrorText: String;
|
|---|
| 280 | var
|
|---|
| 281 | i: Integer;
|
|---|
| 282 | begin
|
|---|
| 283 | Result := '';
|
|---|
| 284 | SetLength(Result, 100);
|
|---|
| 285 | for i := 0 to 99 do
|
|---|
| 286 | begin
|
|---|
| 287 | if errtxt[i] = #0 then
|
|---|
| 288 | begin
|
|---|
| 289 | SetLength(Result, i);
|
|---|
| 290 | exit;
|
|---|
| 291 | end;
|
|---|
| 292 | Result[i+1] := errtxt[i];
|
|---|
| 293 | end;
|
|---|
| 294 | end;
|
|---|
| 295 |
|
|---|
| 296 | function zint_symbol.GetText: String;
|
|---|
| 297 | var
|
|---|
| 298 | i: Integer;
|
|---|
| 299 | begin
|
|---|
| 300 | Result := '';
|
|---|
| 301 | SetLength(Result, 128);
|
|---|
| 302 | for i := 0 to 127 do
|
|---|
| 303 | begin
|
|---|
| 304 | if text[i] = 0 then
|
|---|
| 305 | begin
|
|---|
| 306 | SetLength(Result, i);
|
|---|
| 307 | exit;
|
|---|
| 308 | end;
|
|---|
| 309 | Result[i+1] := char(text[i]);
|
|---|
| 310 | end;
|
|---|
| 311 | end;
|
|---|
| 312 |
|
|---|
| 313 | procedure zint_symbol.SetErrorText(const AErrTxt: String);
|
|---|
| 314 | var
|
|---|
| 315 | i, n: Integer;
|
|---|
| 316 | begin
|
|---|
| 317 | n := Length(AErrTxt);
|
|---|
| 318 | if n > 100 then n := 100;
|
|---|
| 319 | FillChar(errtxt, 100, 0);
|
|---|
| 320 | for i := 1 to n do
|
|---|
| 321 | errtxt[i-1] := AErrTxt[i];
|
|---|
| 322 | end;
|
|---|
| 323 |
|
|---|
| 324 | procedure zint_symbol.SetText(const AText: String);
|
|---|
| 325 | var
|
|---|
| 326 | i, n: Integer;
|
|---|
| 327 | begin
|
|---|
| 328 | n := Length(AText);
|
|---|
| 329 | if n > 128 then n := 128;
|
|---|
| 330 | FillChar(text, 128, 0);
|
|---|
| 331 | for i := 1 to n do
|
|---|
| 332 | text[i-1] := ord(AText[i]);
|
|---|
| 333 | end;
|
|---|
| 334 |
|
|---|
| 335 | end.
|
|---|