• Welcome to PlanetSquires Forums.
 

Barcode DLL (zint 32-bit 64-bit)

Started by Johan Klassen, November 06, 2022, 07:42:29 AM

Previous topic - Next topic

Johan Klassen

since Paul recommended Zint I had another look at their GitHub repo https://github.com/zint/zint and there have been recent updated and building binaries is easy with msys2
fbFrog translates the zint.h with no problem
zint.bi
#pragma once

extern "C"

#define ZINT_H

#inclib "zint"

type zint_vector_rect
    x as single
    y as single
    height as single
    width as single
    colour as long
    next as zint_vector_rect ptr
end type

type zint_vector_hexagon
    x as single
    y as single
    diameter as single
    rotation as long
    next as zint_vector_hexagon ptr
end type

type zint_vector_string
    x as single
    y as single
    fsize as single
    width as single
    length as long
    rotation as long
    halign as long
    text as ubyte ptr
    next as zint_vector_string ptr
end type

type zint_vector_circle
    x as single
    y as single
    diameter as single
    width as single
    colour as long
    next as zint_vector_circle ptr
end type

type zint_vector
    width as single
    height as single
    rectangles as zint_vector_rect ptr
    hexagons as zint_vector_hexagon ptr
    strings as zint_vector_string ptr
    circles as zint_vector_circle ptr
end type

type zint_structapp
    index as long
    count as long
    id as zstring * 32
end type

type zint_symbol
    symbology as long
    height as single
    scale as single
    whitespace_width as long
    whitespace_height as long
    border_width as long
    output_options as long
    fgcolour as zstring * 10
    bgcolour as zstring * 10
    fgcolor as zstring ptr
    bgcolor as zstring ptr
    outfile as zstring * 256
    primary as zstring * 128
    option_1 as long
    option_2 as long
    option_3 as long
    show_hrt as long
    fontsize as long
    input_mode as long
    eci as long
    dot_size as single
    guard_descent as single
    structapp as zint_structapp
    warn_level as long
    debug as long
    text(0 to 127) as ubyte
    rows as long
    width as long
    encoded_data(0 to 199, 0 to 143) as ubyte
    row_height(0 to 199) as single
    errtxt as zstring * 100
    bitmap as ubyte ptr
    bitmap_width as long
    bitmap_height as long
    alphamap as ubyte ptr
    bitmap_byte_length as ulong
    vector as zint_vector ptr
end type

type zint_seg
    source as ubyte ptr
    length as long
    eci as long
end type

const BARCODE_CODE11 = 1
const BARCODE_C25STANDARD = 2
const BARCODE_C25MATRIX = 2
const BARCODE_C25INTER = 3
const BARCODE_C25IATA = 4
const BARCODE_C25LOGIC = 6
const BARCODE_C25IND = 7
const BARCODE_CODE39 = 8
const BARCODE_EXCODE39 = 9
const BARCODE_EANX = 13
const BARCODE_EANX_CHK = 14
const BARCODE_GS1_128 = 16
const BARCODE_EAN128 = 16
const BARCODE_CODABAR = 18
const BARCODE_CODE128 = 20
const BARCODE_DPLEIT = 21
const BARCODE_DPIDENT = 22
const BARCODE_CODE16K = 23
const BARCODE_CODE49 = 24
const BARCODE_CODE93 = 25
const BARCODE_FLAT = 28
const BARCODE_DBAR_OMN = 29
const BARCODE_RSS14 = 29
const BARCODE_DBAR_LTD = 30
const BARCODE_RSS_LTD = 30
const BARCODE_DBAR_EXP = 31
const BARCODE_RSS_EXP = 31
const BARCODE_TELEPEN = 32
const BARCODE_UPCA = 34
const BARCODE_UPCA_CHK = 35
const BARCODE_UPCE = 37
const BARCODE_UPCE_CHK = 38
const BARCODE_POSTNET = 40
const BARCODE_MSI_PLESSEY = 47
const BARCODE_FIM = 49
const BARCODE_LOGMARS = 50
const BARCODE_PHARMA = 51
const BARCODE_PZN = 52
const BARCODE_PHARMA_TWO = 53
const BARCODE_CEPNET = 54
const BARCODE_PDF417 = 55
const BARCODE_PDF417COMP = 56
const BARCODE_PDF417TRUNC = 56
const BARCODE_MAXICODE = 57
const BARCODE_QRCODE = 58
const BARCODE_CODE128B = 60
const BARCODE_AUSPOST = 63
const BARCODE_AUSREPLY = 66
const BARCODE_AUSROUTE = 67
const BARCODE_AUSREDIRECT = 68
const BARCODE_ISBNX = 69
const BARCODE_RM4SCC = 70
const BARCODE_DATAMATRIX = 71
const BARCODE_EAN14 = 72
const BARCODE_VIN = 73
const BARCODE_CODABLOCKF = 74
const BARCODE_NVE18 = 75
const BARCODE_JAPANPOST = 76
const BARCODE_KOREAPOST = 77
const BARCODE_DBAR_STK = 79
const BARCODE_RSS14STACK = 79
const BARCODE_DBAR_OMNSTK = 80
const BARCODE_RSS14STACK_OMNI = 80
const BARCODE_DBAR_EXPSTK = 81
const BARCODE_RSS_EXPSTACK = 81
const BARCODE_PLANET = 82
const BARCODE_MICROPDF417 = 84
const BARCODE_USPS_IMAIL = 85
const BARCODE_ONECODE = 85
const BARCODE_PLESSEY = 86
const BARCODE_TELEPEN_NUM = 87
const BARCODE_ITF14 = 89
const BARCODE_KIX = 90
const BARCODE_AZTEC = 92
const BARCODE_DAFT = 93
const BARCODE_DPD = 96
const BARCODE_MICROQR = 97
const BARCODE_HIBC_128 = 98
const BARCODE_HIBC_39 = 99
const BARCODE_HIBC_DM = 102
const BARCODE_HIBC_QR = 104
const BARCODE_HIBC_PDF = 106
const BARCODE_HIBC_MICPDF = 108
const BARCODE_HIBC_BLOCKF = 110
const BARCODE_HIBC_AZTEC = 112
const BARCODE_DOTCODE = 115
const BARCODE_HANXIN = 116
const BARCODE_MAILMARK = 121
const BARCODE_AZRUNE = 128
const BARCODE_CODE32 = 129
const BARCODE_EANX_CC = 130
const BARCODE_GS1_128_CC = 131
const BARCODE_EAN128_CC = 131
const BARCODE_DBAR_OMN_CC = 132
const BARCODE_RSS14_CC = 132
const BARCODE_DBAR_LTD_CC = 133
const BARCODE_RSS_LTD_CC = 133
const BARCODE_DBAR_EXP_CC = 134
const BARCODE_RSS_EXP_CC = 134
const BARCODE_UPCA_CC = 135
const BARCODE_UPCE_CC = 136
const BARCODE_DBAR_STK_CC = 137
const BARCODE_RSS14STACK_CC = 137
const BARCODE_DBAR_OMNSTK_CC = 138
const BARCODE_RSS14_OMNI_CC = 138
const BARCODE_DBAR_EXPSTK_CC = 139
const BARCODE_RSS_EXPSTACK_CC = 139
const BARCODE_CHANNEL = 140
const BARCODE_CODEONE = 141
const BARCODE_GRIDMATRIX = 142
const BARCODE_UPNQR = 143
const BARCODE_ULTRA = 144
const BARCODE_RMQR = 145
const BARCODE_BC412 = 146
const BARCODE_LAST = 146
const BARCODE_NO_ASCII = &h0001
const BARCODE_BIND = &h0002
const BARCODE_BOX = &h0004
const BARCODE_STDOUT = &h0008
const READER_INIT = &h0010
const SMALL_TEXT = &h0020
const BOLD_TEXT = &h0040
const CMYK_COLOUR = &h0080
const BARCODE_DOTTY_MODE = &h0100
const GS1_GS_SEPARATOR = &h0200
const OUT_BUFFER_INTERMEDIATE = &h0400
const BARCODE_QUIET_ZONES = &h0800
const BARCODE_NO_QUIET_ZONES = &h1000
const COMPLIANT_HEIGHT = &h2000
const DATA_MODE = 0
const UNICODE_MODE = 1
const GS1_MODE = 2
const ESCAPE_MODE = &h0008
const GS1PARENS_MODE = &h0010
const GS1NOCHECK_MODE = &h0020
const HEIGHTPERROW_MODE = &h0040
const FAST_MODE = &h0080
const DM_SQUARE = 100
const DM_DMRE = 101
const ZINT_FULL_MULTIBYTE = 200
const ULTRA_COMPRESSION = 128
const ZINT_WARN_INVALID_OPTION = 2
const ZINT_WARN_USES_ECI = 3
const ZINT_WARN_NONCOMPLIANT = 4
const ZINT_ERROR = 5
const ZINT_ERROR_TOO_LONG = 5
const ZINT_ERROR_INVALID_DATA = 6
const ZINT_ERROR_INVALID_CHECK = 7
const ZINT_ERROR_INVALID_OPTION = 8
const ZINT_ERROR_ENCODING_PROBLEM = 9
const ZINT_ERROR_FILE_ACCESS = 10
const ZINT_ERROR_MEMORY = 11
const ZINT_ERROR_FILE_WRITE = 12
const ZINT_ERROR_USES_ECI = 13
const ZINT_ERROR_NONCOMPLIANT = 14
const WARN_DEFAULT = 0
const WARN_FAIL_ALL = 2
const ZINT_CAP_HRT = &h0001
const ZINT_CAP_STACKABLE = &h0002
const ZINT_CAP_EXTENDABLE = &h0004
const ZINT_CAP_COMPOSITE = &h0008
const ZINT_CAP_ECI = &h0010
const ZINT_CAP_GS1 = &h0020
const ZINT_CAP_DOTTY = &h0040
const ZINT_CAP_QUIET_ZONES = &h0080
const ZINT_CAP_FIXED_RATIO = &h0100
const ZINT_CAP_READER_INIT = &h0200
const ZINT_CAP_FULL_MULTIBYTE = &h0400
const ZINT_CAP_MASK = &h0800
const ZINT_CAP_STRUCTAPP = &h1000
const ZINT_CAP_COMPLIANT_HEIGHT = &h2000
const ZINT_MAX_DATA_LEN = 17400
const ZINT_MAX_SEG_COUNT = 256
const ZINT_DEBUG_PRINT = &h0001
const ZINT_DEBUG_TEST = &h0002
'' TODO: # define ZINT_EXTERN extern

declare function ZBarcode_Create() as zint_symbol ptr
declare sub ZBarcode_Clear(byval symbol as zint_symbol ptr)
declare sub ZBarcode_Delete(byval symbol as zint_symbol ptr)
declare function ZBarcode_Encode(byval symbol as zint_symbol ptr, byval source as const ubyte ptr, byval length as long) as long
declare function ZBarcode_Encode_Segs(byval symbol as zint_symbol ptr, byval segs as const zint_seg ptr, byval seg_count as const long) as long
declare function ZBarcode_Encode_File(byval symbol as zint_symbol ptr, byval filename as const zstring ptr) as long
declare function ZBarcode_Print(byval symbol as zint_symbol ptr, byval rotate_angle as long) as long
'declare function ZBarcode_Encode_and_Print(byval symbol as zint_symbol ptr, byval source as const ubyte ptr, byval length as long, byval rotate_angle as long) as long
declare function ZBarcode_Encode_and_Print(byval symbol as zint_symbol ptr, byval source as const zstring ptr, byval length as long, byval rotate_angle as long) as long
declare function ZBarcode_Encode_Segs_and_Print(byval symbol as zint_symbol ptr, byval segs as const zint_seg ptr, byval seg_count as const long, byval rotate_angle as long) as long
declare function ZBarcode_Encode_File_and_Print(byval symbol as zint_symbol ptr, byval filename as const zstring ptr, byval rotate_angle as long) as long
declare function ZBarcode_Buffer(byval symbol as zint_symbol ptr, byval rotate_angle as long) as long
declare function ZBarcode_Encode_and_Buffer(byval symbol as zint_symbol ptr, byval source as const ubyte ptr, byval length as long, byval rotate_angle as long) as long
declare function ZBarcode_Encode_Segs_and_Buffer(byval symbol as zint_symbol ptr, byval segs as const zint_seg ptr, byval seg_count as const long, byval rotate_angle as long) as long
declare function ZBarcode_Encode_File_and_Buffer(byval symbol as zint_symbol ptr, byval filename as const zstring ptr, byval rotate_angle as long) as long
declare function ZBarcode_Buffer_Vector(byval symbol as zint_symbol ptr, byval rotate_angle as long) as long
declare function ZBarcode_Encode_and_Buffer_Vector(byval symbol as zint_symbol ptr, byval source as const ubyte ptr, byval length as long, byval rotate_angle as long) as long
declare function ZBarcode_Encode_Segs_and_Buffer_Vector(byval symbol as zint_symbol ptr, byval segs as const zint_seg ptr, byval seg_count as const long, byval rotate_angle as long) as long
declare function ZBarcode_Encode_File_and_Buffer_Vector(byval symbol as zint_symbol ptr, byval filename as const zstring ptr, byval rotate_angle as long) as long
declare function ZBarcode_ValidID(byval symbol_id as long) as long
declare function ZBarcode_BarcodeName(byval symbol_id as long, byval name as zstring ptr) as long
declare function ZBarcode_Cap(byval symbol_id as long, byval cap_flag as ulong) as ulong
declare function ZBarcode_Version() as long

end extern

--edit-- I changed ubyte ptr to zstring ptr in function ZBarcode_Encode_and_Print
png of the tiny test

Johan Klassen

a tiny test
#include "zint.bi"

dim as zint_symbol ptr my_symbol
my_symbol = ZBarcode_Create()
ZBarcode_Encode_and_Print(my_symbol, "1010101", 0, 0)
ZBarcode_Delete(my_symbol)

Johan Klassen

#2
tiny test2
#include "zint.bi"

dim as zint_symbol ptr my_symbol
my_symbol = ZBarcode_Create()
my_symbol->symbology=BARCODE_QRCODE
my_symbol->scale=8
my_symbol->outfile="C:\Users\Admin\Desktop\PlanetSquires.png"
ZBarcode_Encode_and_Print(my_symbol, "PlanetSquires", 0, 0)
ZBarcode_Delete(my_symbol)

Paul Squires

Wow, that's awesome Johan! I bet that Peter will be VERY happy with what you've done. Thanks for taking the time to create this.

I am going to try to separate your posts out into a standalone thread so that it will be easier to search for and find in the future.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Johan Klassen

here's the Qt5 GUI front end, the 7zip compressed file is almost 25 MB and the extracted folder is about 100 MB https://drive.google.com/file/d/1saN4bmbDl3QJG2jqV3swD7BshpgCU8aZ/view?usp=sharing
you need to launch it by running the file gui-frontend.bat because it needs to setup the environment variable QT_QPA_PLATFORM_PLUGIN_PATH to the plugins\platforms folder without which the program won't run

Petrus Vorster

#5
You guys are amazing!
Thank you.

Regards, Peter
-Regards
Peter

Petrus Vorster

Wow. This works amazingly well and fast too!

You have solved years of bad borcodes for me!

Thank you very much.

Regards, Peter
-Regards
Peter