Jump to content

Search the Community

Showing results for tags 'barcode'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 10 results

  1. Here a first draft for creating barcodes using the Zint.dll (v2.15.09). Mor information about Zint can be found here: https://zint.org.uk Zint, libzint and Zint Barcode Studio are Copyright © 2022 Robin Stuart. All historical versions are distributed under the GNU General Public License version 3 or later. Version 2.5 (and later) is released under a dual license: the encoding library is released under the BSD license whereas the GUI, Zint Barcode Studio, is released under the GNU General Public License version 3 or later. The code became too long to post here! -> Download from my OneDrive: Zint Zint.au3 ;Coded by UEZ ;v0.70 build 2026-07-29 beta ;IMPORTANT: You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name! ; Distributing copies of the program in compiled format (exe) must be free of any fee! #include-once #include <GDIPlus.au3> #include "ZintDll.au3" Global $g__ZintDLL = @AutoItX64 ? (@ScriptDir & "\Zint64.dll") : (@ScriptDir & "\Zint.dll") #Region Constances ; === Barcode Symbologies === Global Const $BARCODE_CODE11 = 1 ; Code 11 Global Const $BARCODE_C25STANDARD = 2 ; 2 of 5 Standard (Matrix) Global Const $BARCODE_C25MATRIX = 2 ; Legacy Global Const $BARCODE_C25INTER = 3 ; 2 of 5 Interleaved Global Const $BARCODE_C25IATA = 4 ; 2 of 5 IATA Global Const $BARCODE_C25LOGIC = 6 ; 2 of 5 Data Logic Global Const $BARCODE_C25IND = 7 ; 2 of 5 Industrial Global Const $BARCODE_CODE39 = 8 ; Code 39 Global Const $BARCODE_EXCODE39 = 9 ; Extended Code 39 Global Const $BARCODE_EAN8 = 10 ; EAN-8 (GTIN-8) Global Const $BARCODE_EAN_2ADDON = 11 ; EAN/UPC 2-digit add-on Global Const $BARCODE_EAN_5ADDON = 12 ; EAN/UPC 5-digit add-on Global Const $BARCODE_EANX = 13 ; Legacy Global Const $BARCODE_EANX_CHK = 14 ; Legacy Global Const $BARCODE_EAN13 = 15 ; EAN-13 (GTIN-13) Global Const $BARCODE_GS1_128 = 16 ; GS1-128 Global Const $BARCODE_EAN128 = 16 ; Legacy Global Const $BARCODE_CODABAR = 18 ; Codabar Global Const $BARCODE_CODE128 = 20 ; Code 128 Global Const $BARCODE_DPLEIT = 21 ; Deutsche Post Leitcode Global Const $BARCODE_DPIDENT = 22 ; Deutsche Post Identcode Global Const $BARCODE_CODE16K = 23 ; Code 16k Global Const $BARCODE_CODE49 = 24 ; Code 49 Global Const $BARCODE_CODE93 = 25 ; Code 93 Global Const $BARCODE_FLAT = 28 ; Flattermarken Global Const $BARCODE_DBAR_OMN = 29 ; GS1 DataBar Omnidirectional Global Const $BARCODE_RSS14 = 29 ; Legacy Global Const $BARCODE_DBAR_LTD = 30 ; GS1 DataBar Limited Global Const $BARCODE_RSS_LTD = 30 ; Legacy Global Const $BARCODE_DBAR_EXP = 31 ; GS1 DataBar Expanded Global Const $BARCODE_RSS_EXP = 31 ; Legacy Global Const $BARCODE_TELEPEN = 32 ; Telepen Alpha Global Const $BARCODE_UPCA = 34 ; UPC-A Global Const $BARCODE_UPCA_CHK = 35 ; UPC-A including check digit Global Const $BARCODE_UPCE = 37 ; UPC-E Global Const $BARCODE_UPCE_CHK = 38 ; UPC-E including check digit Global Const $BARCODE_POSTNET = 40 ; USPS POSTNET Global Const $BARCODE_MSI_PLESSEY = 47 ; MSI Plessey Global Const $BARCODE_FIM = 49 ; Facing Identification Mark Global Const $BARCODE_LOGMARS = 50 ; LOGMARS Global Const $BARCODE_PHARMA = 51 ; Pharmacode One-Track Global Const $BARCODE_PZN = 52 ; Pharmazentralnummer Global Const $BARCODE_PHARMA_TWO = 53 ; Pharmacode Two-Track Global Const $BARCODE_CEPNET = 54 ; Brazilian CEPNet Postal Code Global Const $BARCODE_PDF417 = 55 ; PDF417 Global Const $BARCODE_PDF417COMP = 56 ; Compact PDF417 Global Const $BARCODE_PDF417TRUNC = 56 ; Legacy Global Const $BARCODE_MAXICODE = 57 ; MaxiCode Global Const $BARCODE_QRCODE = 58 ; QR Code Global Const $BARCODE_CODE128AB = 60 ; Code 128 (Suppress Code Set C) Global Const $BARCODE_CODE128B = 60 ; Legacy Global Const $BARCODE_AUSPOST = 63 ; Australia Post Standard Customer Global Const $BARCODE_AUSREPLY = 66 ; Australia Post Reply Paid Global Const $BARCODE_AUSROUTE = 67 ; Australia Post Routing Global Const $BARCODE_AUSREDIRECT = 68 ; Australia Post Redirection Global Const $BARCODE_ISBNX = 69 ; ISBN Global Const $BARCODE_RM4SCC = 70 ; Royal Mail 4-State Global Const $BARCODE_DATAMATRIX = 71 ; Data Matrix (ECC200) Global Const $BARCODE_EAN14 = 72 ; EAN-14 Global Const $BARCODE_VIN = 73 ; Vehicle Identification Number Global Const $BARCODE_CODABLOCKF = 74 ; Codablock-F Global Const $BARCODE_NVE18 = 75 ; NVE-18 (SSCC-18) Global Const $BARCODE_JAPANPOST = 76 ; Japanese Postal Code Global Const $BARCODE_KOREAPOST = 77 ; Korea Post Global Const $BARCODE_DBAR_STK = 79 ; GS1 DataBar Stacked Global Const $BARCODE_RSS14STACK = 79 ; Legacy Global Const $BARCODE_DBAR_OMNSTK = 80 ; GS1 DataBar Stacked Omnidirectional Global Const $BARCODE_RSS14STACK_OMNI = 80 ; Legacy Global Const $BARCODE_DBAR_EXPSTK = 81 ; GS1 DataBar Expanded Stacked Global Const $BARCODE_RSS_EXPSTACK = 81 ; Legacy Global Const $BARCODE_PLANET = 82 ; USPS PLANET Global Const $BARCODE_MICROPDF417 = 84 ; MicroPDF417 Global Const $BARCODE_USPS_IMAIL = 85 ; USPS Intelligent Mail Global Const $BARCODE_ONECODE = 85 ; Legacy Global Const $BARCODE_PLESSEY = 86 ; UK Plessey Global Const $BARCODE_TELEPEN_NUM = 87 ; Telepen Numeric Global Const $BARCODE_ITF14 = 89 ; ITF-14 Global Const $BARCODE_KIX = 90 ; Dutch Post KIX Global Const $BARCODE_AZTEC = 92 ; Aztec Global Const $BARCODE_DAFT = 93 ; DAFT Global Const $BARCODE_DPD = 96 ; DPD Global Const $BARCODE_MICROQR = 97 ; Micro QR Global Const $BARCODE_HIBC_128 = 98 ; HIBC Code 128 Global Const $BARCODE_HIBC_39 = 99 ; HIBC Code 39 Global Const $BARCODE_HIBC_DM = 102 ; HIBC Data Matrix Global Const $BARCODE_HIBC_QR = 104 ; HIBC QR Global Const $BARCODE_HIBC_PDF = 106 ; HIBC PDF417 Global Const $BARCODE_HIBC_MICPDF = 108 ; HIBC MicroPDF417 Global Const $BARCODE_HIBC_BLOCKF = 110 ; HIBC Codablock-F Global Const $BARCODE_HIBC_AZTEC = 112 ; HIBC Aztec Global Const $BARCODE_DOTCODE = 115 ; DotCode Global Const $BARCODE_HANXIN = 116 ; Han Xin Global Const $BARCODE_MAILMARK_2D = 119 ; Royal Mail 2D Mailmark Global Const $BARCODE_UPU_S10 = 120 ; UPU S10 Global Const $BARCODE_MAILMARK_4S = 121 ; Royal Mail 4-State Mailmark Global Const $BARCODE_MAILMARK = 121 ; Legacy Global Const $BARCODE_AZRUNE = 128 ; Aztec Runes Global Const $BARCODE_CODE32 = 129 ; Code 32 Global Const $BARCODE_EANX_CC = 130 ; Legacy Global Const $BARCODE_GS1_128_CC = 131 ; GS1-128 Composite Global Const $BARCODE_EAN128_CC = 131 ; Legacy Global Const $BARCODE_DBAR_OMN_CC = 132 ; DataBar Omnidirectional Composite Global Const $BARCODE_RSS14_CC = 132 ; Legacy Global Const $BARCODE_DBAR_LTD_CC = 133 ; DataBar Limited Composite Global Const $BARCODE_RSS_LTD_CC = 133 ; Legacy Global Const $BARCODE_DBAR_EXP_CC = 134 ; DataBar Expanded Composite Global Const $BARCODE_RSS_EXP_CC = 134 ; Legacy Global Const $BARCODE_UPCA_CC = 135 ; UPC-A Composite Global Const $BARCODE_UPCE_CC = 136 ; UPC-E Composite Global Const $BARCODE_DBAR_STK_CC = 137 ; DataBar Stacked Composite Global Const $BARCODE_RSS14STACK_CC = 137 ; Legacy Global Const $BARCODE_DBAR_OMNSTK_CC = 138 ; DataBar Stacked Omnidirectional Composite Global Const $BARCODE_RSS14_OMNI_CC = 138 ; Legacy Global Const $BARCODE_DBAR_EXPSTK_CC = 139 ; DataBar Expanded Stacked Composite Global Const $BARCODE_RSS_EXPSTACK_CC = 139 ; Legacy Global Const $BARCODE_CHANNEL = 140 ; Channel Code Global Const $BARCODE_CODEONE = 141 ; Code One Global Const $BARCODE_GRIDMATRIX = 142 ; Grid Matrix Global Const $BARCODE_UPNQR = 143 ; UPNQR Global Const $BARCODE_ULTRA = 144 ; Ultracode Global Const $BARCODE_RMQR = 145 ; Rectangular Micro QR Global Const $BARCODE_BC412 = 146 ; IBM BC412 Global Const $BARCODE_DXFILMEDGE = 147 ; DX Film Edge Global Const $BARCODE_EAN8_CC = 148 ; EAN-8 Composite Global Const $BARCODE_EAN13_CC = 149 ; EAN-13 Composite Global Const $BARCODE_LAST = 149 ; Max marker ; === Output options === Global Const $BARCODE_BIND_TOP = 0x00001 ; Bind top Global Const $BARCODE_BIND = 0x00002 ; Bind bottom Global Const $BARCODE_BOX = 0x00004 ; Box around symbol Global Const $BARCODE_STDOUT = 0x00008 ; Output to stdout Global Const $READER_INIT = 0x00010 ; Reader Initialisation Global Const $SMALL_TEXT = 0x00020 ; Small human readable text Global Const $BOLD_TEXT = 0x00040 ; Bold human readable text Global Const $CMYK_COLOUR = 0x00080 ; Use CMYK in EPS Global Const $BARCODE_DOTTY_MODE = 0x00100 ; Dotty mode Global Const $GS1_GS_SEPARATOR = 0x00200 ; Use GS as separator Global Const $OUT_BUFFER_INTERMEDIATE = 0x00400 ; Return intermediate data Global Const $BARCODE_QUIET_ZONES = 0x00800 ; Force quiet zones Global Const $BARCODE_NO_QUIET_ZONES = 0x01000 ; Suppress quiet zones Global Const $COMPLIANT_HEIGHT = 0x02000 ; Compliant height Global Const $EANUPC_GUARD_WHITESPACE = 0x04000 ; Guard whitespace Global Const $EMBED_VECTOR_FONT = 0x08000 ; Embed vector font Global Const $BARCODE_MEMORY_FILE = 0x10000 ; Output to memory Global Const $BARCODE_RAW_TEXT = 0x20000 ; Output raw text ; === Input modes === Global Const $DATA_MODE = 0 ; Binary input Global Const $UNICODE_MODE = 1 ; Unicode input Global Const $GS1_MODE = 2 ; GS1 input Global Const $ESCAPE_MODE = 0x0008 ; Escape sequences Global Const $GS1PARENS_MODE = 0x0010 ; GS1 parentheses Global Const $GS1NOCHECK_MODE = 0x0020 ; Skip GS1 checks Global Const $HEIGHTPERROW_MODE = 0x0040 ; Height per row Global Const $FAST_MODE = 0x0080 ; Fast mode Global Const $EXTRA_ESCAPE_MODE = 0x0100 ; Extra escape Global Const $GS1SYNTAXENGINE_MODE = 0x0200 ; GS1 syntax engine ; === Data Matrix options === Global Const $DM_SQUARE = 100 ; Square only Global Const $DM_DMRE = 101 ; DMRE only Global Const $DM_ISO_144 = 128 ; ISO 144 compliance ; === QR/Han Xin/Grid Matrix options === Global Const $ZINT_FULL_MULTIBYTE = 200 ; Full multibyte ; === Ultracode options === Global Const $ULTRA_COMPRESSION = 128 ; Compression mode ; === Warnings & Errors === Global Const $ZINT_WARN_HRT_TRUNCATED = 1 ; HRT truncated Global Const $ZINT_WARN_INVALID_OPTION = 2 ; Invalid option Global Const $ZINT_WARN_USES_ECI = 3 ; Uses ECI Global Const $ZINT_WARN_NONCOMPLIANT = 4 ; Noncompliant symbol Global Const $ZINT_ERROR = 5 ; General error Global Const $ZINT_ERROR_TOO_LONG = 5 ; Data too long Global Const $ZINT_ERROR_INVALID_DATA = 6 ; Invalid data Global Const $ZINT_ERROR_INVALID_CHECK = 7 ; Invalid check digit Global Const $ZINT_ERROR_INVALID_OPTION = 8 ; Invalid option Global Const $ZINT_ERROR_ENCODING_PROBLEM = 9 ; Encoding problem Global Const $ZINT_ERROR_FILE_ACCESS = 10 ; File access error Global Const $ZINT_ERROR_MEMORY = 11 ; Memory error Global Const $ZINT_ERROR_FILE_WRITE = 12 ; File write error Global Const $ZINT_ERROR_USES_ECI = 13 ; Uses ECI Global Const $ZINT_ERROR_NONCOMPLIANT = 14 ; Noncompliant Global Const $ZINT_ERROR_HRT_TRUNCATED = 15 ; HRT truncated ; === Warning levels === Global Const $WARN_DEFAULT = 0 ; Default warnings Global Const $WARN_FAIL_ALL = 2 ; Treat all warnings as errors ; === Capabilities === Global Const $ZINT_CAP_HRT = 0x0001 ; Has HRT Global Const $ZINT_CAP_STACKABLE = 0x0002 ; Stackable Global Const $ZINT_CAP_EANUPC = 0x0004 ; EAN/UPC Global Const $ZINT_CAP_EXTENDABLE = 0x0004 ; Extendable (legacy) Global Const $ZINT_CAP_COMPOSITE = 0x0008 ; Composite Global Const $ZINT_CAP_ECI = 0x0010 ; ECI capable Global Const $ZINT_CAP_GS1 = 0x0020 ; GS1 capable Global Const $ZINT_CAP_DOTTY = 0x0040 ; Dotty capable Global Const $ZINT_CAP_QUIET_ZONES = 0x0080 ; Quiet zones Global Const $ZINT_CAP_FIXED_RATIO = 0x0100 ; Fixed ratio Global Const $ZINT_CAP_READER_INIT = 0x0200 ; Reader Init Global Const $ZINT_CAP_FULL_MULTIBYTE = 0x0400 ; Full multibyte Global Const $ZINT_CAP_MASK = 0x0800 ; Masking Global Const $ZINT_CAP_STRUCTAPP = 0x1000 ; Structured Append Global Const $ZINT_CAP_COMPLIANT_HEIGHT = 0x2000 ; Compliant height Global Const $ZINT_CAP_BINDABLE = 0x4000 ; Bindable ; === Debug flags === Global Const $ZINT_DEBUG_PRINT = 1 ; Print debug info to stdout Global Const $ZINT_DEBUG_TEST = 2 ; Test mode ; === Source encodings for the Encode functions (see $iEncoding parameter) === Global Const $ZINT_SRC_ANSI = 1 ; Convert AutoIt string to ANSI bytes (use with $DATA_MODE) Global Const $ZINT_SRC_UTF8 = 4 ; Convert AutoIt string to UTF-8 bytes (use with $UNICODE_MODE) - default ; === Limits === Global Const $ZINT_MAX_DATA_LEN = 17400 ; Max data length Global Const $ZINT_MAX_SEG_COUNT = 256 ; Max segment count #EndRegion #Region Structs ; Vector elements Global Const $tag_zint_vector_rect = "struct;" & _ "float x;" & _ ; Top left "float y;" & _ "float height;" & _ "float width;" & _ "long colour;" & _ ; -1 foreground, 1-8 = Cyan, Blue, Magenta, Red, Yellow, Green, Black, White "ptr next;" & _ ; Pointer to next rectangle "endstruct" Global Const $tag_zint_vector_hexagon = "struct;" & _ "float x;" & _ ; Centre x "float y;" & _ ; Centre y "float diameter;" & _ ; Short diameter (inscribed circle) "long rotation;" & _ ; 0, 90, 180, 270 (0 = apex at top) "ptr next;" & _ ; Pointer to next hexagon "endstruct" Global Const $tag_zint_vector_string = "struct;" & _ "float x;" & _ ; Relative to halign "float y;" & _ ; Relative to baseline "float fsize;" & _ ; Font size "float width;" & _ ; Rendered width estimate "long length;" & _ ; Number of characters (bytes) "long rotation;" & _ ; 0, 90, 180, 270 "long halign;" & _ ; 0 = centre, 1 = left, 2 = right "ptr text;" & _ ; UTF-8, NUL-terminated "ptr next;" & _ ; Pointer to next string "endstruct" Global Const $tag_zint_vector_circle = "struct;" & _ "float x;" & _ ; Centre x "float y;" & _ ; Centre y "float diameter;" & _ ; Circle diameter (excludes width) "float width;" & _ ; Perimeter width, 0 = fill "long colour;" & _ ; 0 = foreground colour, else background "ptr next;" & _ ; Pointer to next circle "endstruct" Global Const $tag_zint_vector = "struct;" & _ "float width;" & _ ; Overall barcode width "float height;" & _ ; Overall barcode height "ptr rectangles;" & _ ; Pointer to first rectangle "ptr hexagons;" & _ ; Pointer to first hexagon "ptr strings;" & _ ; Pointer to first string "ptr circles;" & _ ; Pointer to first circle "endstruct" ; Structured Append info Global Const $tag_zint_structapp = "long index;" & _ ; Position in sequence (1-based) "long count;" & _ ; Number of symbols in sequence "char id[32];" ; Optional ID, ASCII, NUL-terminated ; Segment info Global Const $tag_zint_seg = "struct;" & _ "ptr source;" & _ ; Data pointer "long length;" & _ ; Data length (0 = NUL-terminated) "long eci;" & _ ; Extended Channel Interpretation "endstruct" ; Main symbol structure ; NOTE: this layout matches the Zint 2.15.0.9 development snapshot (errtxt[160], raw_segs present, ; encoded_data still ahead of errtxt). Zint 2.15.0 release has errtxt[100] and no raw_segs, ; Zint 2.16.0 moved encoded_data/row_height to the very end and renamed raw_segs to content_segs. ; Call ZBarcode_CheckLayout() once after ZBarcode_Create() to verify the DLL matches. Global Const $tag_zint_symbol = "struct;" & _ "long symbology;" & _ ; Symbol type "float height;" & _ ; Barcode height "float scale;" & _ ; Scale factor "long whitespace_width;" & _ ; Horizontal whitespace "long whitespace_height;" & _ ; Vertical whitespace "long border_width;" & _ ; Border width "long output_options;" & _ ; Output options "char fgcolour[16];" & _ ; Foreground colour string "char bgcolour[16];" & _ ; Background colour string "ptr fgcolor;" & _ ; Pointer to fgcolour "ptr bgcolor;" & _ ; Pointer to bgcolour "char outfile[256];" & _ ; Output filename "char primary[128];" & _ ; Primary message data "long option_1;" & _ ; Symbol-specific option "long option_2;" & _ "long option_3;" & _ "long show_hrt;" & _ ; Show (1) / hide (0) human readable text "long input_mode;" & _ ; Input encoding "long eci;" & _ ; Extended Channel Interpretation "float dpmm;" & _ ; Resolution in dots/mm "float dot_size;" & _ ; Dot size (dotty mode) "float text_gap;" & _ ; Gap between barcode and text "float guard_descent;" & _ ; EAN/UPC guard bar descent $tag_zint_structapp & _ ; Structured append info "long warn_level;" & _ ; Warning behaviour "long debug;" & _ ; Debug flags "byte text[256];" & _ ; Human-readable text (output, UTF-8) "long text_length;" & _ ; Length of text (output) "long rows;" & _ ; Number of rows (output) "long width;" & _ ; Symbol width (output) "byte encoded_data[28800];" & _ ; Encoded data (flattened 200x144) "float row_height[200];" & _ ; Row heights "char errtxt[160];" & _ ; Error text (output) "ptr bitmap;" & _ ; Bitmap pointer (output) "long bitmap_width;" & _ ; Bitmap width "long bitmap_height;" & _ ; Bitmap height "ptr alphamap;" & _ ; Alpha channel pointer "ptr vector;" & _ ; Vector header pointer "ptr memfile;" & _ ; In-memory file buffer "long memfile_size;" & _ ; Buffer length "ptr raw_segs;" & _ ; Raw segments pointer "long raw_seg_count;" & _ ; Number of raw segs "endstruct" #EndRegion #Region Internal helpers ; Convert an AutoIt string (or Binary) into a NUL-terminated byte buffer for Zint. ; Returns the payload length in BYTES (without the terminator). Func __Zint_MakeSource(Const $vInput, ByRef $tBuffer, $iEncoding = $ZINT_SRC_UTF8) Local $bData = IsBinary($vInput) ? Binary($vInput) : StringToBinary($vInput, $iEncoding) Local $iLen = BinaryLen($bData) $tBuffer = DllStructCreate("byte data[" & $iLen + 1 & "]") If @error Then Return SetError(1, 0, 0) If $iLen Then DllStructSetData($tBuffer, "data", $bData) DllStructSetData($tBuffer, "data", 0, $iLen + 1) ; NUL terminator Return $iLen EndFunc ; Read a NUL-terminated / length-limited UTF-8 string from a pointer Func __Zint_UTF8PtrToStr($pText, $iLen = 0) If Not $pText Then Return "" If $iLen < 1 Then Local $a = DllCall("msvcrt.dll", "uint_ptr:cdecl", "strlen", "ptr", $pText) If @error Then Return "" $iLen = $a[0] EndIf If $iLen < 1 Then Return "" Local $tStr = DllStructCreate("byte data[" & $iLen & "]", $pText) If @error Then Return "" Return BinaryToString(DllStructGetData($tStr, "data"), $ZINT_SRC_UTF8) EndFunc ; Only 0/90/180/270 are accepted by Zint Func __Zint_NormAngle($iAngle) Local $i = Mod(Round($iAngle / 90) * 90, 360) Return $i < 0 ? $i + 360 : $i EndFunc ; Map a zint_vector colour index to an ARGB value Func __Zint_VecColour($iColour, $iFgARGB, $iBgARGB) Switch $iColour Case -1 Return $iFgARGB Case 1 Return 0xFF00FFFF ; Cyan Case 2 Return 0xFF0000FF ; Blue Case 3 Return 0xFFFF00FF ; Magenta Case 4 Return 0xFFFF0000 ; Red Case 5 Return 0xFFFFFF00 ; Yellow Case 6 Return 0xFF00FF00 ; Green Case 7 Return 0xFF000000 ; Black Case 8 Return 0xFFFFFFFF ; White Case Else Return $iBgARGB EndSwitch EndFunc #EndRegion #Region Functions ; Create and initialize a symbol structure Func ZBarcode_Create() If Not FileExists($g__ZintDLL) Then If @AutoItX64 Then _zint64dll(True) Else _zintdll(True) EndIf EndIf Local $aCall = DllCall($g__ZintDLL, "ptr:cdecl", "ZBarcode_Create") If @error Then Return SetError(1, 0, 0) If $aCall[0] = 0 Then Return SetError(2, 0, 0) Return $aCall[0] EndFunc ; Free any output buffers that may have been created and initialize output fields Func ZBarcode_Clear($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Clear", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; Free any output buffers that may have been created and reset all fields to defaults Func ZBarcode_Reset($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Reset", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; Free a symbol structure, including any output buffers Func ZBarcode_Delete($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Delete", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; Verify that $tag_zint_symbol matches the loaded DLL. Returns 1 if the layout looks sane. ; A mismatch means the DLL was built from a different Zint revision than this UDF describes. Func ZBarcode_CheckLayout() Local $pSymbol = ZBarcode_Create() If @error Then Return SetError(1, 0, 0) Local $t = DllStructCreate($tag_zint_symbol, $pSymbol) ; Freshly created symbols always carry these defaults Local $bHead = ($t.symbology = $BARCODE_CODE128) And ($t.scale = 1) And ($t.show_hrt = 1) And _ (StringLeft($t.outfile, 4) = "out.") And ($t.guard_descent = 5) ; Encode a tiny symbol to validate everything behind errtxt (bitmap fields) $t.symbology = $BARCODE_CODE128 ZBarcode_Encode_and_Buffer($pSymbol, "1") Local $bTail = ($t.bitmap <> 0) And ($t.bitmap_width > 0) And ($t.bitmap_width < 100000) And _ ($t.bitmap_height > 0) And ($t.bitmap_height < 100000) ZBarcode_Delete($pSymbol) If Not $bHead Then Return SetError(2, 0, 0) ; front of the struct is wrong If Not $bTail Then Return SetError(3, 0, 0) ; errtxt size / trailing fields are wrong Return 1 EndFunc ; =================================================================== ; Encoding ; =================================================================== ; Encode a barcode. $vInput may be a string or a Binary value. Func ZBarcode_Encode($pSymbol, $vInput, $iEncoding = $ZINT_SRC_UTF8) Local $tInput, $iLength = __Zint_MakeSource($vInput, $tInput, $iEncoding) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc ; Encode a barcode with multiple ECI segments Func ZBarcode_Encode_Segs($pSymbol, $pSegs, $iSegCount) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc ; Encode a barcode using input data from file Func ZBarcode_Encode_File($pSymbol, $sFilename) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File", "ptr", $pSymbol, "str", $sFilename) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc ; =================================================================== ; Output to file ; =================================================================== ; Output a previously encoded symbol to file Func ZBarcode_Print($pSymbol, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Print", "ptr", $pSymbol, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc ; Encode and output a symbol to file Func ZBarcode_Encode_and_Print($pSymbol, $vInput, $iRotate = 0, $iEncoding = $ZINT_SRC_UTF8) Local $tInput, $iLength = __Zint_MakeSource($vInput, $tInput, $iEncoding) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Print", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc ; Encode a symbol with multiple ECI segments and output to file Func ZBarcode_Encode_Segs_and_Print($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Print", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc ; Encode a symbol using input data from file and output to file Func ZBarcode_Encode_File_and_Print($pSymbol, $sFilename, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Print", "ptr", $pSymbol, "str", $sFilename, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc ; =================================================================== ; Output to memory (raster/vector) ; =================================================================== Func ZBarcode_Buffer($pSymbol, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Buffer", "ptr", $pSymbol, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc Func ZBarcode_Encode_and_Buffer($pSymbol, $vInput, $iRotate = 0, $iEncoding = $ZINT_SRC_UTF8) Local $tInput, $iLength = __Zint_MakeSource($vInput, $tInput, $iEncoding) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Buffer", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc Func ZBarcode_Encode_Segs_and_Buffer($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Buffer", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc Func ZBarcode_Encode_File_and_Buffer($pSymbol, $sFilename, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Buffer", "ptr", $pSymbol, "str", $sFilename, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc Func ZBarcode_Buffer_Vector($pSymbol, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Buffer_Vector", "ptr", $pSymbol, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc Func ZBarcode_Encode_and_Buffer_Vector($pSymbol, $vInput, $iRotate = 0, $iEncoding = $ZINT_SRC_UTF8) Local $tInput, $iLength = __Zint_MakeSource($vInput, $tInput, $iEncoding) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Buffer_Vector", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc Func ZBarcode_Encode_Segs_and_Buffer_Vector($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Buffer_Vector", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc Func ZBarcode_Encode_File_and_Buffer_Vector($pSymbol, $sFilename, $iRotate = 0) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Buffer_Vector", "ptr", $pSymbol, "str", $sFilename, "long", __Zint_NormAngle($iRotate)) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return 1 EndFunc ; =================================================================== ; Info & Validation ; =================================================================== ; Is symbol_id a recognized symbology? Func ZBarcode_ValidID($iSymbolID) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_ValidID", "long", $iSymbolID) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ; Copy BARCODE_XXX name of symbol_id into name buffer Func ZBarcode_BarcodeName($iSymbolID) Local $tName = DllStructCreate("char name[32]") Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_BarcodeName", "long", $iSymbolID, "struct*", $tName) If @error Then Return SetError(-1, 0, "") If $aCall[0] Then Return SetError($aCall[0], 0, "") Return DllStructGetData($tName, "name") EndFunc ; Return the capability flags for symbology symbol_id that match cap_flag Func ZBarcode_Cap($iSymbolID, $iCapFlag) Local $aCall = DllCall($g__ZintDLL, "uint:cdecl", "ZBarcode_Cap", "long", $iSymbolID, "uint", $iCapFlag) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ; =================================================================== ; X-dimension & Scaling ; =================================================================== Func ZBarcode_Default_Xdim($iSymbolID) Local $aCall = DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_Default_Xdim", "long", $iSymbolID) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Func ZBarcode_Scale_From_XdimDp($iSymbolID, $fXDimMM, $fDpmm, $sFiletype = "") Local $aCall = DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_Scale_From_XdimDp", "long", $iSymbolID, "float", $fXDimMM, "float", $fDpmm, "str", $sFiletype) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Func ZBarcode_XdimDp_From_Scale($iSymbolID, $fScale, $fXDimOrDpmm, $sFiletype = "") Local $aCall = DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_XdimDp_From_Scale", "long", $iSymbolID, "float", $fScale, "float", $fXDimOrDpmm, "str", $sFiletype) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ; =================================================================== ; UTF-8 & ECI helpers ; =================================================================== ; Convert a UTF-8 source string into the given ECI encoding. $sDest receives the converted bytes as Binary. Func ZBarcode_UTF8_To_ECI($iEci, $sSource, ByRef $vDest) $vDest = "" Local $tSrc, $iLength = __Zint_MakeSource($sSource, $tSrc, $ZINT_SRC_UTF8) ; Ask Zint how big the destination buffer has to be instead of guessing Local $iNeeded = ZBarcode_Dest_Len_ECI($iEci, $sSource) If @error Then Return SetError(@error, 0, 0) Local $tDest = DllStructCreate("byte data[" & $iNeeded + 1 & "]") Local $tDestLen = DllStructCreate("int len") DllStructSetData($tDestLen, "len", $iNeeded) Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_UTF8_To_ECI", "long", $iEci, "struct*", $tSrc, "long", $iLength, "struct*", $tDest, "struct*", $tDestLen) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Local $iOut = DllStructGetData($tDestLen, "len") If $iOut < 1 Then Return SetError(0, 0, 1) ; Only return the bytes actually written, not the whole buffer $vDest = BinaryMid(DllStructGetData($tDest, "data"), 1, $iOut) Return 1 EndFunc ; Length in bytes needed to hold $sSource converted from UTF-8 to $iEci Func ZBarcode_Dest_Len_ECI($iEci, $sSource) Local $tSrc, $iLength = __Zint_MakeSource($sSource, $tSrc, $ZINT_SRC_UTF8) Local $tDestLen = DllStructCreate("int len") Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Dest_Len_ECI", "long", $iEci, "struct*", $tSrc, "long", $iLength, "struct*", $tDestLen) If @error Then Return SetError(-1, 0, 0) If $aCall[0] Then Return SetError($aCall[0], 0, 0) Return DllStructGetData($tDestLen, "len") EndFunc ; =================================================================== ; Build info ; =================================================================== Func ZBarcode_NoPng() Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_NoPng") If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Func ZBarcode_HaveGS1SyntaxEngine() Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_HaveGS1SyntaxEngine") If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ; Return the version of Zint linked to, e.g. "2.15.0" or "2.15.0.9" for a development build Func ZBarcode_Version() Local $aCall = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Version") If @error Then Return SetError(1, 0, "") Local $iVer = $aCall[0] If $iVer < 10000 Then Return SetError(2, 0, "") ; Release builds encode major*10000 + minor*100 + release, ; development builds append the build number as two more digits If $iVer >= 1000000 Then Return StringFormat("%i.%i.%i.%i", Int($iVer / 1000000), Mod(Int($iVer / 10000), 100), Mod(Int($iVer / 100), 100), Mod($iVer, 100)) EndIf Return StringFormat("%i.%i.%i", Int($iVer / 10000), Mod(Int($iVer / 100), 100), Mod($iVer, 100)) EndFunc ; =================================================================== ; Convenience wrappers ; =================================================================== ; Error / warning message of the last operation Func ZBarcode_ErrTxt($t_zint_symbol) If Not IsDllStruct($t_zint_symbol) Then Return SetError(1, 0, "") Return DllStructGetData($t_zint_symbol, "errtxt") EndFunc ; Human Readable Text produced by the last encode (UTF-8) Func ZBarcode_HRT($t_zint_symbol) If Not IsDllStruct($t_zint_symbol) Then Return SetError(1, 0, "") Local $iLen = $t_zint_symbol.text_length If $iLen < 1 Then Return "" If $iLen > 256 Then $iLen = 256 Return BinaryToString(BinaryMid(DllStructGetData($t_zint_symbol, "text"), 1, $iLen), $ZINT_SRC_UTF8) EndFunc ; Content of the in-memory output file ($BARCODE_MEMORY_FILE) as Binary Func ZBarcode_GetMemFile($t_zint_symbol) If Not IsDllStruct($t_zint_symbol) Then Return SetError(1, 0, "") Local $pMem = $t_zint_symbol.memfile, $iSize = $t_zint_symbol.memfile_size If Not $pMem Or $iSize < 1 Then Return SetError(2, 0, "") Local $tMem = DllStructCreate("byte data[" & $iSize & "]", $pMem) If @error Then Return SetError(3, 0, "") Return DllStructGetData($tMem, "data") EndFunc ; Build a contiguous zint_seg array from a 2D array [[text, eci], ...]. ; $aKeepAlive receives the text buffers - it MUST stay in scope until encoding is done! Func ZBarcode_CreateSegs(Const ByRef $aSegs, ByRef $aKeepAlive) If Not IsArray($aSegs) Or UBound($aSegs, 0) <> 2 Or UBound($aSegs, 2) < 2 Then Return SetError(1, 0, 0) Local $iCount = UBound($aSegs) If $iCount < 1 Or $iCount > $ZINT_MAX_SEG_COUNT Then Return SetError(2, 0, 0) ; Derive the element size from the tag so x86 and x64 both work Local $iSegSize = DllStructGetSize(DllStructCreate($tag_zint_seg)) Local $tArray = DllStructCreate("byte seg[" & $iSegSize * $iCount & "]") If @error Then Return SetError(3, 0, 0) Local $pArray = DllStructGetPtr($tArray), $tSeg, $tText, $iLen Local $aBuffers[$iCount] For $i = 0 To $iCount - 1 $iLen = __Zint_MakeSource($aSegs[$i][0], $tText, $ZINT_SRC_UTF8) $aBuffers[$i] = $tText $tSeg = DllStructCreate($tag_zint_seg, $pArray + $i * $iSegSize) $tSeg.source = DllStructGetPtr($tText) $tSeg.length = $iLen $tSeg.eci = $aSegs[$i][1] Next $aKeepAlive = $aBuffers Return $tArray EndFunc ; =================================================================== ; GDI+ rendering ; =================================================================== ; Convert Zint raster buffer to a GDI+ bitmap / GDI bitmap. ; NOTE: $tPixel is only a scratch buffer now - the returned bitmap owns its own pixel memory. Func ZBarcode_DecodeBufferToBitmap($t_zint_symbol, ByRef $tPixel, $bGDI = False) If Not IsDllStruct($t_zint_symbol) Then Return SetError(1, 0, 0) Local $iW = $t_zint_symbol.bitmap_width, $iH = $t_zint_symbol.bitmap_height If $iW < 1 Or $iH < 1 Then Return SetError(2, 0, 0) Local $pSrc = $t_zint_symbol.bitmap If Not $pSrc Then Return SetError(2, 0, 0) ; ZBarcode_Buffer() has not been called yet ; Zint stores tightly packed rows of width * 3 bytes, GDI+ needs a DWORD aligned stride Local $iRowBytes = $iW * 3 Local $iStride = BitAND($iRowBytes + 3, BitNOT(3)) $tPixel = DllStructCreate("byte rgb[" & $iStride * $iH & "]") If @error Then Return SetError(3, 0, 0) Local $pDst = DllStructGetPtr($tPixel) If $iStride = $iRowBytes Then DllCall("msvcrt.dll", "ptr:cdecl", "memcpy", "ptr", $pDst, "ptr", $pSrc, "uint_ptr", $iRowBytes * $iH) If @error Then Return SetError(4, 0, 0) Else For $y = 0 To $iH - 1 DllCall("msvcrt.dll", "ptr:cdecl", "memcpy", "ptr", $pDst + $y * $iStride, "ptr", $pSrc + $y * $iRowBytes, "uint_ptr", $iRowBytes) If @error Then Return SetError(4, 0, 0) Next EndIf Local $hSrc = _GDIPlus_BitmapCreateFromScan0($iW, $iH, $GDIP_PXF24RGB, $iStride, $pDst) If @error Or Not $hSrc Then Return SetError(5, 0, 0) ; Zint delivers RGB, GDI+ 24bpp is BGR in memory -> swap red and blue with a colour matrix Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH, $GDIP_PXF24RGB) If @error Or Not $hBitmap Then _GDIPlus_ImageDispose($hSrc) Return SetError(5, 0, 0) EndIf Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $tCM = DllStructCreate("float m[25]") DllStructSetData($tCM, "m", 1, 3) ; new red = old blue DllStructSetData($tCM, "m", 1, 7) ; new green = old green DllStructSetData($tCM, "m", 1, 11) ; new blue = old red DllStructSetData($tCM, "m", 1, 19) ; alpha DllStructSetData($tCM, "m", 1, 25) Local $hIA = _GDIPlus_ImageAttributesCreate() _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tCM) _GDIPlus_GraphicsSetInterpolationMode($hGfx, 5) ; nearest neighbour, keep the modules crisp _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 2) _GDIPlus_GraphicsDrawImageRectRect($hGfx, $hSrc, 0, 0, $iW, $iH, 0, 0, $iW, $iH, $hIA) _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hSrc) If $bGDI Then Local $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) If @error Or Not $hBitmap_GDI Then _GDIPlus_ImageDispose($hBitmap) Return SetError(6, 0, 0) EndIf _GDIPlus_ImageDispose($hBitmap) Return $hBitmap_GDI EndIf Return $hBitmap EndFunc ; Size of the vector output as [width, height] Func ZBarcode_VectorSize($t_zint_symbol) If Not IsDllStruct($t_zint_symbol) Then Return SetError(1, 0, 0) If Not $t_zint_symbol.vector Then Return SetError(2, 0, 0) Local $tVector = DllStructCreate($tag_zint_vector, $t_zint_symbol.vector) Local $aSize[2] = [$tVector.width, $tVector.height] Return $aSize EndFunc ; Draw a vector symbol (created with one of the *_Buffer_Vector functions) into a GDI+ graphics context. ; Handles rectangles, hexagons (MaxiCode), circles (bullseye / dotty mode) and the human readable text. Func ZBarcode_VectorDraw($t_zint_symbol, $hGraphics, $iFgARGB = 0xFF000000, $iBgARGB = 0xFFFFFFFF, $sFont = "Arial", $fOffsetX = 0, $fOffsetY = 0) If Not IsDllStruct($t_zint_symbol) Then Return SetError(1, 0, 0) If Not $t_zint_symbol.vector Then Return SetError(2, 0, 0) Local $tVector = DllStructCreate($tag_zint_vector, $t_zint_symbol.vector) Local $hBrush = _GDIPlus_BrushCreateSolid($iFgARGB) Local $tItem, $pItem ; --- Rectangles (the bars / modules) --- $pItem = $tVector.rectangles While $pItem $tItem = DllStructCreate($tag_zint_vector_rect, $pItem) _GDIPlus_BrushSetSolidColor($hBrush, __Zint_VecColour($tItem.colour, $iFgARGB, $iBgARGB)) _GDIPlus_GraphicsFillRect($hGraphics, $fOffsetX + $tItem.x, $fOffsetY + $tItem.y, $tItem.width, $tItem.height, $hBrush) $pItem = $tItem.next WEnd ; --- Hexagons (MaxiCode) --- $pItem = $tVector.hexagons If $pItem Then _GDIPlus_BrushSetSolidColor($hBrush, $iFgARGB) Local $hPath = _GDIPlus_PathCreate(), $fR, $fA, $fX1, $fY1, $fX2, $fY2 While $pItem $tItem = DllStructCreate($tag_zint_vector_hexagon, $pItem) ; diameter is the short (inscribed) one -> circumradius = r / cos(30) $fR = ($tItem.diameter / 2) / 0.866025403784439 _GDIPlus_PathStartFigure($hPath) For $i = 0 To 5 $fA = ($tItem.rotation + 90 + $i * 60) * 0.0174532925199433 $fX1 = $fOffsetX + $tItem.x + $fR * Cos($fA) $fY1 = $fOffsetY + $tItem.y - $fR * Sin($fA) $fA = ($tItem.rotation + 90 + ($i + 1) * 60) * 0.0174532925199433 $fX2 = $fOffsetX + $tItem.x + $fR * Cos($fA) $fY2 = $fOffsetY + $tItem.y - $fR * Sin($fA) _GDIPlus_PathAddLine($hPath, $fX1, $fY1, $fX2, $fY2) Next _GDIPlus_PathCloseFigure($hPath) $pItem = $tItem.next WEnd _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush) _GDIPlus_PathDispose($hPath) EndIf ; --- Circles (MaxiCode bullseye, dotty mode) --- $pItem = $tVector.circles Local $iCol, $fD, $hPen While $pItem $tItem = DllStructCreate($tag_zint_vector_circle, $pItem) $iCol = $tItem.colour ? $iBgARGB : $iFgARGB $fD = $tItem.diameter If $tItem.width > 0 Then ; ring, diameter excludes the perimeter width $hPen = _GDIPlus_PenCreate($iCol, $tItem.width) _GDIPlus_GraphicsDrawEllipse($hGraphics, $fOffsetX + $tItem.x - $fD / 2, $fOffsetY + $tItem.y - $fD / 2, $fD, $fD, $hPen) _GDIPlus_PenDispose($hPen) Else _GDIPlus_BrushSetSolidColor($hBrush, $iCol) _GDIPlus_GraphicsFillEllipse($hGraphics, $fOffsetX + $tItem.x - $fD / 2, $fOffsetY + $tItem.y - $fD / 2, $fD, $fD, $hBrush) EndIf $pItem = $tItem.next WEnd ; --- Human readable text --- $pItem = $tVector.strings If $pItem Then Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) If Not $hFamily Then $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $fEm = _GDIPlus_FontFamilyGetEmHeight($hFamily, 0) Local $fAscent = _GDIPlus_FontFamilyGetCellAscent($hFamily, 0) Local $fAscRatio = ($fEm > 0) ? ($fAscent / $fEm) : 0.9 Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFont, $tLayout, $sText, $iAlign, $iState _GDIPlus_BrushSetSolidColor($hBrush, $iFgARGB) _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, 4) ; anti aliased While $pItem $tItem = DllStructCreate($tag_zint_vector_string, $pItem) $sText = __Zint_UTF8PtrToStr($tItem.text, $tItem.length) If $sText <> "" Then ; halign: 0 = centre, 1 = left, 2 = right -> StringFormat: 0 = near, 1 = centre, 2 = far Switch $tItem.halign Case 1 $iAlign = 0 Case 2 $iAlign = 2 Case Else $iAlign = 1 EndSwitch _GDIPlus_StringFormatSetAlign($hFormat, $iAlign) ; Font size is given in pixels, y refers to the baseline $hFont = _GDIPlus_FontCreate($hFamily, $tItem.fsize, 0, 2) $tLayout = _GDIPlus_RectFCreate($fOffsetX + $tItem.x, $fOffsetY + $tItem.y - $tItem.fsize * $fAscRatio, 0, 0) If $tItem.rotation Then ; save/restore instead of reset, otherwise a transform set by the caller would be lost $iState = _GDIPlus_GraphicsSave($hGraphics) _GDIPlus_GraphicsTranslateTransform($hGraphics, $fOffsetX + $tItem.x, $fOffsetY + $tItem.y) _GDIPlus_GraphicsRotateTransform($hGraphics, $tItem.rotation) $tLayout = _GDIPlus_RectFCreate(0, -$tItem.fsize * $fAscRatio, 0, 0) _GDIPlus_GraphicsDrawStringEx($hGraphics, $sText, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsRestore($hGraphics, $iState) Else _GDIPlus_GraphicsDrawStringEx($hGraphics, $sText, $hFont, $tLayout, $hFormat, $hBrush) EndIf _GDIPlus_FontDispose($hFont) EndIf $pItem = $tItem.next WEnd _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) EndIf _GDIPlus_BrushDispose($hBrush) Return 1 EndFunc ; Render a vector symbol into a fresh GDI+ bitmap Func ZBarcode_VectorToBitmap($t_zint_symbol, $iFgARGB = 0xFF000000, $iBgARGB = 0xFFFFFFFF, $sFont = "Arial", $fPadding = 0) Local $aSize = ZBarcode_VectorSize($t_zint_symbol) If @error Then Return SetError(@error, 0, 0) Local $iW = Ceiling($aSize[0] + 2 * $fPadding), $iH = Ceiling($aSize[1] + 2 * $fPadding) If $iW < 1 Or $iH < 1 Then Return SetError(3, 0, 0) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH, $GDIP_PXF32ARGB) If @error Or Not $hBitmap Then Return SetError(4, 0, 0) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 2) _GDIPlus_GraphicsClear($hGfx, $iBgARGB) ZBarcode_VectorDraw($t_zint_symbol, $hGfx, $iFgARGB, $iBgARGB, $sFont, $fPadding, $fPadding) _GDIPlus_GraphicsDispose($hGfx) Return $hBitmap EndFunc #EndRegion Example1.au3 #AutoIt3Wrapper_UseX64=y #include "Zint.au3" Global Const $sTestFile = @ScriptDir & "\out.png" ;absolute path, otherwise the working directory decides where it lands If FileExists($sTestFile) Then FileDelete($sTestFile) Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) ConsoleWrite("Zint DLL version: " & ZBarcode_Version() & @CRLF) ConsoleWrite("PNG support: " & (ZBarcode_NoPng() ? "No" : "Yes") & @CRLF) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB) If @error Then ZBarcode_Delete($pZB) Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) EndIf With $t_zint_symbol .symbology = $BARCODE_CODE128 .scale = 2 .show_hrt = 1 .output_options = BitOR($SMALL_TEXT, $BARCODE_QUIET_ZONES) .outfile = $sTestFile EndWith ZBarcode_Encode_and_Print($pZB, "12340984576") Global $iError = @error If $iError Then ConsoleWrite("! Zint says: " & ZBarcode_ErrTxt($t_zint_symbol) & @CRLF) ConsoleWrite("HRT: " & ZBarcode_HRT($t_zint_symbol) & @CRLF) ZBarcode_Delete($pZB) If Not $iError And FileExists($sTestFile) Then ShellExecute($sTestFile) Else MsgBox(16, "Error", "Code was not created. Error: " & $iError, 5) EndIf Example2.au3 #AutoIt3Wrapper_UseX64=n #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "Zint.au3" Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB) With $t_zint_symbol .symbology = $BARCODE_QRCODE .input_mode = $UNICODE_MODE ;the UDF hands the text over as UTF-8 .scale = 10 .fgcolour = "202080" ;coloured foreground - proves the red/blue channels are not swapped anymore .bgcolour = "FFFFF0" EndWith If Not ZBarcode_Encode_and_Buffer($pZB, "Hello QR World ;-)") Then Global $iErr = @error MsgBox(16, "ERROR", "Unable to encode!" & @CRLF & ZBarcode_ErrTxt($t_zint_symbol), 10) ZBarcode_Delete($pZB) Exit $iErr EndIf _GDIPlus_Startup() Global $tBitmapData = 0 Global $hBitmap = ZBarcode_DecodeBufferToBitmap($t_zint_symbol, $tBitmapData) Global $iW = $t_zint_symbol.bitmap_width, $iH = $t_zint_symbol.bitmap_height ZBarcode_Delete($pZB) ;the bitmap is independent from the symbol now $tBitmapData = 0 Global Const $hGUI = GUICreate("Test QR Code", $iW, $iH) ; a picture control keeps the image on screen - Windows repaints it for us Global Const $idPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) Global $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp)) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hHBmp) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() Example3.au3 #AutoIt3Wrapper_UseX64=y #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "Zint.au3" Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB), $sText = "12340984576" With $t_zint_symbol .symbology = $BARCODE_CODE128 .scale = 3 .show_hrt = 1 EndWith If Not ZBarcode_Encode_and_Buffer_Vector($pZB, $sText) Then MsgBox(16, "ERROR", "Unable to encode!" & @CRLF & ZBarcode_ErrTxt($t_zint_symbol), 10) ZBarcode_Delete($pZB) Exit EndIf Global $aSize = ZBarcode_VectorSize($t_zint_symbol) ConsoleWrite($aSize[0] & " x " & $aSize[1] & @CRLF) _GDIPlus_Startup() ;the renderer walks all rectangles (including the very last one) and draws the HRT from the symbol itself Global $hBitmap = ZBarcode_VectorToBitmap($t_zint_symbol, 0xFF000000, 0xFFFFFFFF, "Arial", 8) Global $iW = _GDIPlus_ImageGetWidth($hBitmap), $iH = _GDIPlus_ImageGetHeight($hBitmap) ZBarcode_Delete($pZB) Global Const $hGUI = GUICreate("Test Bar Code 128", $iW, $iH) ; a picture control keeps the image on screen - Windows repaints it for us Global Const $idPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) Global $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp)) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hHBmp) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() Example4.au3 #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #include "Zint.au3" ; =================================================================== ; Zint AutoIt Demo Test ; =================================================================== ; ------------------------------------------------------------------- ; Step 1: Create a symbol and verify the struct layout ; ------------------------------------------------------------------- ConsoleWrite("Step 1: Create a symbol" & @CRLF) Global $pSymbol = ZBarcode_Create() If @error Then MsgBox(16, "Error", "Failed to create symbol") Exit EndIf Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pSymbol) ConsoleWrite("Symbol created: " & $pSymbol & @CRLF) ConsoleWrite("Struct layout matches the DLL: " & (ZBarcode_CheckLayout() ? "yes" : "NO - error " & @error) & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 2: Configure the symbol BEFORE encoding ; ------------------------------------------------------------------- ConsoleWrite("Step 2: Configure and encode" & @CRLF) With $t_zint_symbol .symbology = $BARCODE_CODE128 .input_mode = $UNICODE_MODE .height = 50 .scale = 1 .show_hrt = 1 .outfile = @ScriptDir & "\demo.png" EndWith Global $sData = "HELLO123" If ZBarcode_Encode($pSymbol, $sData) Then ConsoleWrite("Encoding succeeded, HRT: " & ZBarcode_HRT($t_zint_symbol) & @CRLF) Else ConsoleWrite("Encoding failed, error: " & @error & " - " & ZBarcode_ErrTxt($t_zint_symbol) & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 3: Output to raster buffer ; ------------------------------------------------------------------- ConsoleWrite("Step 3: Output to raster buffer" & @CRLF) If ZBarcode_Buffer($pSymbol) Then ConsoleWrite("Raster buffer: " & $t_zint_symbol.bitmap_width & " x " & $t_zint_symbol.bitmap_height & @CRLF) Else ConsoleWrite("Raster buffer generation failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 4: Output to vector buffer ; ------------------------------------------------------------------- ConsoleWrite("Step 4: Output to vector buffer" & @CRLF) If ZBarcode_Buffer_Vector($pSymbol) Then Global $aSize = ZBarcode_VectorSize($t_zint_symbol) ConsoleWrite("Vector buffer: " & $aSize[0] & " x " & $aSize[1] & @CRLF) Else ConsoleWrite("Vector buffer generation failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 5: Print to file ; ------------------------------------------------------------------- ConsoleWrite("Step 5: Print to file" & @CRLF) If ZBarcode_Print($pSymbol) Then ConsoleWrite("Written to " & $t_zint_symbol.outfile & @CRLF) Else ConsoleWrite("Print failed, error: " & @error & " - " & ZBarcode_ErrTxt($t_zint_symbol) & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 6: Get barcode info ; ------------------------------------------------------------------- ConsoleWrite("Step 6: Get barcode info" & @CRLF) ConsoleWrite("Valid ID for CODE128: " & ZBarcode_ValidID($BARCODE_CODE128) & @CRLF) ConsoleWrite("Barcode name for CODE128: " & ZBarcode_BarcodeName($BARCODE_CODE128) & @CRLF) ConsoleWrite("Default X-dim for CODE128: " & ZBarcode_Default_Xdim($BARCODE_CODE128) & " mm" & @CRLF) ConsoleWrite("QR supports ECI: " & (ZBarcode_Cap($BARCODE_QRCODE, $ZINT_CAP_ECI) ? "yes" : "no") & @CRLF) ConsoleWrite("QR supports Structured Append: " & (ZBarcode_Cap($BARCODE_QRCODE, $ZINT_CAP_STRUCTAPP) ? "yes" : "no") & @CRLF) ConsoleWrite("Scale for 0.5 mm X-dim at 12 dpmm: " & ZBarcode_Scale_From_XdimDp($BARCODE_CODE128, 0.5, 12, "png") & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 7: UTF-8 to ECI conversion test ; ------------------------------------------------------------------- ConsoleWrite("Step 7: UTF-8 to ECI conversion test" & @CRLF) Global $vDest ConsoleWrite("Bytes needed for ECI 9 (Greek): " & ZBarcode_Dest_Len_ECI(9, "Hello") & @CRLF) If ZBarcode_UTF8_To_ECI(3, "HELLO", $vDest) Then ConsoleWrite("UTF-8 to ECI 3 (Latin-1): " & $vDest & " -> " & BinaryToString($vDest) & @CRLF) Else ConsoleWrite("UTF-8 to ECI conversion failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 8: Check Zint build info ; ------------------------------------------------------------------- ConsoleWrite("Step 8: Check Zint build info" & @CRLF) ConsoleWrite("Zint No PNG support: " & ZBarcode_NoPng() & @CRLF) ConsoleWrite("Zint GS1 support: " & ZBarcode_HaveGS1SyntaxEngine() & @CRLF) ConsoleWrite("Zint Version: " & ZBarcode_Version() & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 9: Clear, reset and delete symbol ; ------------------------------------------------------------------- ConsoleWrite("Step 9: Clear, reset and delete symbol" & @CRLF) ZBarcode_Clear($pSymbol) ConsoleWrite("Symbol cleared" & @CRLF) ZBarcode_Reset($pSymbol) ConsoleWrite("Symbol reset" & @CRLF) ZBarcode_Delete($pSymbol) ConsoleWrite("Symbol deleted" & @CRLF) ConsoleWrite(@CRLF) MsgBox(64, "Demo Complete", "Zint AutoIt demo test finished successfully.") Example5.au3 #AutoIt3Wrapper_UseX64=y #include "Zint.au3" Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB) With $t_zint_symbol .symbology = $BARCODE_AZTEC .input_mode = $UNICODE_MODE ;segment data has to be UTF-8 in this mode .scale = 6 .outfile = @ScriptDir & "\segtest.png" EndWith If FileExists($t_zint_symbol.outfile) Then FileDelete($t_zint_symbol.outfile) ; Text plus the matching ECI. The helper converts to UTF-8 and lays the segments ; out as one continuous array - writing them into a "char" struct would have ; turned every non ASCII character into a question mark. Global $aSegs[3][2] = [ _ ["Κείμενο", 9], _ ; Greek -> ISO 8859-7 ["Текст", 7], _ ; Cyrillic -> ISO 8859-5 ["文章", 29]] ; Chinese -> GB 2312 Global $aKeepAlive ;must stay alive until the encoder is done Global $tSegs = ZBarcode_CreateSegs($aSegs, $aKeepAlive) If @error Then Exit MsgBox(16, "ERROR", "Unable to build the segment array", 10) Global $iError = 0 If Not ZBarcode_Encode_Segs($pZB, DllStructGetPtr($tSegs), UBound($aSegs)) Then $iError = @error MsgBox(16, "ERROR", "ZBarcode_Encode_Segs returned error " & $iError & @CRLF & ZBarcode_ErrTxt($t_zint_symbol), 10) EndIf If Not $iError Then If ZBarcode_Print($pZB) Then ShellExecute($t_zint_symbol.outfile) Else MsgBox(16, "ERROR", "Print failed: " & ZBarcode_ErrTxt($t_zint_symbol), 10) EndIf EndIf ZBarcode_Delete($pZB) More examples on my OneDrive! Please test and reply. Feel free to post examples here!
  2. OPENBARCODES project http://grandzebu.net/index.php?page=/informatique/codbar-en/codbar.htm all is under GPL - GNU license , open source and completely free... I translated original Pascal functions to PowerBuilder syntax which is very similar to AutoIt (BARCODE_powerbuilder.zip). Now I translated all barcode functions to AutoIt syntax (barcode_autoit.zip). BarCode UDF + example --> you must install aproppriate TTF fonts into Windows first. barcode.au3 barcode_test.au3 print.au3 code128.ttf code25I.ttf code39.ttf ean13.ttf Available functions: barcode_128() barcode_ean8() barcode_ean13() barcode_25i() barcode_39() ; TTF fonts must be installed in system first #AutoIt3Wrapper_run_obfuscator=y #Obfuscator_parameters=/so #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <print.au3> #include <barcode.au3> $barcode_test = GUICreate("BarCode Test", 601, 174, -1, -1) GUICtrlCreateLabel("Input:", 11, 10, 30, 17) $Input = GUICtrlCreateInput("", 41, 8, 120, 21) GUICtrlCreateLabel("Output:", 171, 10, 38, 17) $Output = GUICtrlCreateInput("", 209, 8, 120, 21) GUICtrlSetState(-1, $GUI_DISABLE) $print = GUICtrlCreateButton("Print", 340, 7, 39, 23) GUICtrlCreateLabel("Type:", 387, 10, 28, 17) $type = GUICtrlCreateCombo("", 417, 8, 91, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Code 128|EAN 8|EAN 13|Code 2 of 5 i|Code 3 of 9", "Code 128") GUICtrlCreateLabel("Size:", 517, 10, 25, 17) $size = GUICtrlCreateCombo("", 543, 8, 47, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "12|18|24|36|48|60|72", "48") $barcode = GUICtrlCreateLabel("", 10, 39, 580, 130) GUICtrlSetFont(-1, 48, 400, 0, "Code 128") GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $type ChangeFont() ApplyBarcode() Case $size ChangeFont() Case $print Print() EndSwitch WEnd Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $Input Then ApplyBarcode() EndIf EndFunc Func ChangeFont() Switch GUICtrlRead($type) Case 'Code 128' $font_name = 'Code 128' Case 'EAN 8','EAN 13' $font_name = 'Code EAN13' Case 'Code 2 of 5 i' $font_name = 'Code 2 of 5 interleaved' Case 'Code 3 of 9' $font_name = 'Code 3 de 9' EndSwitch GUICtrlSetFont($barcode, GUICtrlRead($size), 400, 0, $font_name) EndFunc Func ApplyBarcode() Switch GUICtrlRead($type) Case 'Code 128' $barcode_data = barcode_128(GUICtrlRead($Input)) Case 'EAN 8' $barcode_data = barcode_ean8(GUICtrlRead($Input)) Case 'EAN 13' $barcode_data = barcode_ean13(GUICtrlRead($Input)) Case 'Code 2 of 5 i' $barcode_data = barcode_25i(GUICtrlRead($Input)) Case 'Code 3 of 9' $barcode_data = barcode_39(GUICtrlRead($Input)) EndSwitch GUICtrlSetData($Output, $barcode_data) GUICtrlSetData($barcode, $barcode_data) EndFunc ; print given text on default printer in given size by all available barcode types Func Print() $sPrinter = _GetDefaultPrinter() If $sPrinter = "" Then Return $hPrintDC = _WinAPI_CreateDC("winspool", $sPrinter) _InitPrinter($hPrintDC, "Printing Barcodes from AutoIt") ; print job name $hFont = _CreateFont_Simple('Arial', 12, $FW_BOLD) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 500, 'Input data: ' & GUICtrlRead($Input), 0xFF0000) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Courier', 10, $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _WinAPI_SetTextColor($hPrintDC, 0x000000) _TextOut_Centered($hPrintDC, 1400, 'Code 128') _TextOut_Centered($hPrintDC, 2400, 'EAN 8') _TextOut_Centered($hPrintDC, 3400, 'EAN 13') _TextOut_Centered($hPrintDC, 4400, 'Code 2 of 5 i') _TextOut_Centered($hPrintDC, 5400, 'Code 3 of 9') _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code 128', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 1500, barcode_128(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code EAN13', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 2500, barcode_ean8(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code EAN13', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 3500, barcode_ean13(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code 2 of 5 interleaved', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 4500, barcode_25i(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code 3 de 9', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 5500, barcode_39(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) _DeInitPrinter($hPrintDC) EndFunc History: 2012-06-01 - only Code 128 translated 2012-06-03 - all functions translated 2012-06-04 - added Print + some inner optimizations Original idea comes from this topic: Previous downloads (AutoIt): 31 BARCODE_powerbuilder.zip barcode_autoit.zip Printing Barcodes from AutoIt.pdf
  3. As I have time, I am converting my old barcode generators from old Pascal source to AutoIt. I will add them all here as I convert them, rather than creating a new topic for each one. There are no global variables involved, so you can safely include any of these without worry about variables being stomped on. No barcode fonts required. Code128Auto - Creates a Code128A/B/C optimized barcode from supplied data Code39 - Creates a Code39 or Code39Extended (with or without check-character) barcode from supplied data (also known as Code 3 of 9). CODABAR - Creates a CODABAR barcode from supplied data (used mainly by libraries and blood banks) NOTE: These will require the StringSize UDF by Melba23 ========== CodeQR - Creates a QRcode from supplied data.
  4. Hi all, i want to start a new application that capture a screen or image from webcam an read all barcode inside the picture. I have test this code https://www.autoitscript.com/forum/topic/27925-webcam-example/ Works fine for my webcam. Now i need to read all barcodes (code 128 code39, no 2d) inside the picture. I have found this https://www.codeproject.com/Articles/42852/Reading-Barcodes-from-an-Image-III It's possible to make a dll from VB source i linked with this parameters : filename, Array of barcode founded, error code and launch from Autoit with function ? Anyone can help me to make dll and autoit function, i don't know VB. Thanks
  5. Now that I have been learning to do a few things with GDI+, I decided it was time to port my old barcode generators to Autoit. It will generate a code length optimized Code128A/B/C barcode. Code128Auto.zip The ZIP file contains the UDF source and a very simple demo. ========== I am consolidating all of my barcode UDFs into one topic. Please refer to the new location for updates. http://www.autoitscript.com/forum/topic/170087-barcode-generators/ ==========
  6. I have seen many different threads about generating barcodes, displaying them, and printing them. However at this point I am completely torn with which method to use. I am making a software that lets the user scan items, enter in information and save it in a SQLite database. For my purposes, I want to be able to display the barcode with number underneath in a similar way to most other controls eg GuiCtrlCreateBarcode( barcodenumber, x, y, width, height ). I also want to be able to print the barcode and have it be readable by the same scanner - The most successful encoding I've found is code128. Here is what I have found so far: This thread has nice code that saves the output as imagesPrinting is easy and scans properlyDisplaying the image on a pic control makes it easy to set it's x/y/width/height But..The code does not let you directly specify the width / height, so displayed image on GUI is ALWAYS skewed.Getting output images the right size with that code is very difficultI cannot find any examples of drawing barcodes to an image that let you specify width / heightThis example Several threads use Static controlsLook very nice on GUI, easy to get explicit position and size But...I know of no way to turn a bunch of static controls into something printableI didn't find any examples that had numbers at the bottom of the barcodeThe third solution I found was using a barcode fontCan look nice, depending on fontShouldn't be hard to print But..Depends on additional font being installedSome fonts don't scan correctlyHow do you specify a width / height of an area you want the barcode to fill when using a font?I'm really at a loss as to how to move forward. Maybe there's an example I missed that is better suited to what I could find? PErhaps someone has experience writing barcode scanning / generating / printing software and can share the experiences. Can someone bounce a few ideas back and forth with me on the best way to proceed?
  7. willichan

    CodeQR.zip

    Version 1.0.0

    2,410 downloads

    Requires quricol32.dll from http://delphi32.blogspot.it/2011/11/quricol-qr-code-generator-library.html Lots of similar implementations, but this one fits with my other barcode libraries.
  8. willichan

    Code39.zip

    Version 1.0.0

    1,616 downloads

    Creates a Code39 or Code39Extended (with or without check-character) barcode from supplied data
  9. Version 1.0.1

    2,141 downloads

    Creates a Code128A/B/C optimized barcode from supplied data
  10. Version 1.0.0

    1,141 downloads

    Creates a CODABAR barcode based on the supplied data. Requires StringSize UDF by Melba23
×
×
  • Create New...