ruby-zint 1.5.0-x86_64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +146 -0
- data/ext/ruby-zint/extconf.rb +113 -0
- data/lib/3.4/libzint.so +0 -0
- data/lib/ruby-zint.rb +1 -0
- data/lib/zint/aus_post.rb +8 -0
- data/lib/zint/aus_redirect.rb +8 -0
- data/lib/zint/aus_reply.rb +8 -0
- data/lib/zint/aus_route.rb +8 -0
- data/lib/zint/azrune.rb +8 -0
- data/lib/zint/aztec.rb +8 -0
- data/lib/zint/barcode.rb +550 -0
- data/lib/zint/bc_412.rb +8 -0
- data/lib/zint/bitmap.rb +4 -0
- data/lib/zint/bitmap_pixel.rb +4 -0
- data/lib/zint/c25iata.rb +8 -0
- data/lib/zint/c25ind.rb +8 -0
- data/lib/zint/c25inter.rb +8 -0
- data/lib/zint/c25logic.rb +8 -0
- data/lib/zint/c25matrix.rb +8 -0
- data/lib/zint/c25standard.rb +8 -0
- data/lib/zint/cep_net.rb +8 -0
- data/lib/zint/channel.rb +8 -0
- data/lib/zint/codabar.rb +8 -0
- data/lib/zint/codablock_f.rb +8 -0
- data/lib/zint/code11.rb +8 -0
- data/lib/zint/code128.rb +8 -0
- data/lib/zint/code128ab.rb +8 -0
- data/lib/zint/code128b.rb +5 -0
- data/lib/zint/code16k.rb +8 -0
- data/lib/zint/code32.rb +8 -0
- data/lib/zint/code39.rb +8 -0
- data/lib/zint/code49.rb +8 -0
- data/lib/zint/code93.rb +8 -0
- data/lib/zint/code_one.rb +8 -0
- data/lib/zint/constants/capability_flags.rb +21 -0
- data/lib/zint/constants/debug_flags.rb +9 -0
- data/lib/zint/constants/errors.rb +20 -0
- data/lib/zint/constants/input_data_types.rb +16 -0
- data/lib/zint/constants/output_options.rb +24 -0
- data/lib/zint/constants/specific_options.rb +13 -0
- data/lib/zint/constants/symbologies.rb +138 -0
- data/lib/zint/constants/warn_levels.rb +9 -0
- data/lib/zint/constants/warnings.rb +12 -0
- data/lib/zint/daft.rb +8 -0
- data/lib/zint/data_matrix.rb +19 -0
- data/lib/zint/dbarexp.rb +8 -0
- data/lib/zint/dbarexpstk.rb +8 -0
- data/lib/zint/dbarltd.rb +8 -0
- data/lib/zint/dbaromn.rb +8 -0
- data/lib/zint/dbaromnstk.rb +8 -0
- data/lib/zint/dbarstk.rb +8 -0
- data/lib/zint/dependencies.rb +15 -0
- data/lib/zint/dot_code.rb +8 -0
- data/lib/zint/dpd.rb +8 -0
- data/lib/zint/dpident.rb +8 -0
- data/lib/zint/dpleit.rb +8 -0
- data/lib/zint/dxfilmedge.rb +8 -0
- data/lib/zint/ean128.rb +8 -0
- data/lib/zint/ean14.rb +8 -0
- data/lib/zint/eanx.rb +8 -0
- data/lib/zint/eanxchk.rb +8 -0
- data/lib/zint/excode39.rb +8 -0
- data/lib/zint/fim.rb +8 -0
- data/lib/zint/flat.rb +8 -0
- data/lib/zint/grid_matrix.rb +8 -0
- data/lib/zint/gs1_128.rb +10 -0
- data/lib/zint/hanxin.rb +8 -0
- data/lib/zint/hibc128.rb +8 -0
- data/lib/zint/hibc39.rb +8 -0
- data/lib/zint/hibcaztec.rb +8 -0
- data/lib/zint/hibcblockf.rb +8 -0
- data/lib/zint/hibcdm.rb +8 -0
- data/lib/zint/hibcmicpdf.rb +8 -0
- data/lib/zint/hibcpdf.rb +8 -0
- data/lib/zint/hibcqr.rb +8 -0
- data/lib/zint/isbnx.rb +8 -0
- data/lib/zint/itf14.rb +8 -0
- data/lib/zint/japan_post.rb +8 -0
- data/lib/zint/kix.rb +8 -0
- data/lib/zint/korea_post.rb +8 -0
- data/lib/zint/logmars.rb +8 -0
- data/lib/zint/mailmark.rb +8 -0
- data/lib/zint/mailmark_2d.rb +8 -0
- data/lib/zint/mailmark_4s.rb +8 -0
- data/lib/zint/maxi_code.rb +8 -0
- data/lib/zint/micro_pdf417.rb +8 -0
- data/lib/zint/micro_qr.rb +8 -0
- data/lib/zint/msiplessey.rb +8 -0
- data/lib/zint/native.rb +106 -0
- data/lib/zint/nve18.rb +8 -0
- data/lib/zint/one_code.rb +8 -0
- data/lib/zint/pdf417.rb +8 -0
- data/lib/zint/pdf417comp.rb +8 -0
- data/lib/zint/pdf417trunc.rb +8 -0
- data/lib/zint/pharma.rb +8 -0
- data/lib/zint/pharmatwo.rb +8 -0
- data/lib/zint/planet.rb +8 -0
- data/lib/zint/plessey.rb +8 -0
- data/lib/zint/postnet.rb +8 -0
- data/lib/zint/pzn.rb +8 -0
- data/lib/zint/qr.rb +18 -0
- data/lib/zint/rmqr.rb +8 -0
- data/lib/zint/rss14.rb +8 -0
- data/lib/zint/rss14stack.rb +8 -0
- data/lib/zint/rss14stackomni.rb +8 -0
- data/lib/zint/rssexp.rb +8 -0
- data/lib/zint/rssexpstack.rb +8 -0
- data/lib/zint/rssltd.rb +8 -0
- data/lib/zint/structs/seg.rb +26 -0
- data/lib/zint/structs/structapp.rb +25 -0
- data/lib/zint/structs/symbol.rb +57 -0
- data/lib/zint/structs/vector.rb +54 -0
- data/lib/zint/structs/vector_circle.rb +32 -0
- data/lib/zint/structs/vector_hexagon.rb +31 -0
- data/lib/zint/structs/vector_rect.rb +37 -0
- data/lib/zint/structs/vector_string.rb +50 -0
- data/lib/zint/telepen.rb +8 -0
- data/lib/zint/telepennum.rb +8 -0
- data/lib/zint/ultra.rb +8 -0
- data/lib/zint/upc_a.rb +8 -0
- data/lib/zint/upc_a_chk.rb +8 -0
- data/lib/zint/upc_e.rb +8 -0
- data/lib/zint/upc_e_chk.rb +8 -0
- data/lib/zint/upnqr.rb +8 -0
- data/lib/zint/upu_s10.rb +8 -0
- data/lib/zint/uspsimail.rb +8 -0
- data/lib/zint/version.rb +3 -0
- data/lib/zint/vin.rb +8 -0
- data/lib/zint/zint_recipe.rb +31 -0
- data/lib/zint.rb +170 -0
- data/ruby-zint.gemspec +43 -0
- metadata +305 -0
data/lib/zint/hibcpdf.rb
ADDED
data/lib/zint/hibcqr.rb
ADDED
data/lib/zint/isbnx.rb
ADDED
data/lib/zint/itf14.rb
ADDED
data/lib/zint/kix.rb
ADDED
data/lib/zint/logmars.rb
ADDED
data/lib/zint/native.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
module Zint
|
2
|
+
module Native
|
3
|
+
extend FFI::Library
|
4
|
+
|
5
|
+
root_path = File.expand_path("../../..", __FILE__)
|
6
|
+
prefix = FFI::Platform::LIBPREFIX.empty? ? "lib" : FFI::Platform::LIBPREFIX
|
7
|
+
bundled_dll = File.join(root_path, "lib/#{prefix}zint.#{FFI::Platform::LIBSUFFIX}")
|
8
|
+
native_gem1 = File.join(root_path, "lib/3.4/libzint.#{RbConfig::CONFIG["DLEXT"]}") # This is where rake-compiler places the file in the gem
|
9
|
+
native_gem2 = File.join(root_path, "lib/3.0/libzint.#{RbConfig::CONFIG["DLEXT"]}") # ... for non-ucrt windows builds
|
10
|
+
ffi_lib [bundled_dll, native_gem1, native_gem2, "libzint.so.2.15", "libzint", "zint"]
|
11
|
+
|
12
|
+
# Error codes (API return values)
|
13
|
+
enum :error_code, [Constants::Warnings::WARNINGS, Constants::Errors::ERRORS].map { |h| h.to_a }.flatten
|
14
|
+
|
15
|
+
# Aliases for better method signatures
|
16
|
+
typedef Structs::Symbol.by_ref, :zint_symbol
|
17
|
+
typedef :pointer, :filename
|
18
|
+
typedef :int32, :length
|
19
|
+
typedef :int32, :rotate_angle
|
20
|
+
typedef :int32, :symbol_id
|
21
|
+
typedef :uint32, :cap_flag
|
22
|
+
typedef :pointer, :source
|
23
|
+
|
24
|
+
# Create and initialize a symbol structure
|
25
|
+
attach_function(:ZBarcode_Create, [], :zint_symbol, blocking: true)
|
26
|
+
|
27
|
+
# Free any output buffers that may have been created and initialize output fields
|
28
|
+
attach_function(:ZBarcode_Clear, [:zint_symbol], :void, blocking: true)
|
29
|
+
|
30
|
+
# Free a symbol structure, including any output buffers
|
31
|
+
#
|
32
|
+
# For use with ruby's garbage collector ZBarcode_Delete must be called with a plain :pointer and not an :zint_symbol.
|
33
|
+
attach_function(:ZBarcode_Delete, [:pointer], :void, blocking: true)
|
34
|
+
|
35
|
+
# Encode a barcode. If `length` is 0, `source` must be NUL-terminated.
|
36
|
+
attach_function(:ZBarcode_Encode, [:zint_symbol, :source, :length], :error_code, blocking: true)
|
37
|
+
|
38
|
+
# Encode a barcode using input data from file `filename`
|
39
|
+
attach_function(:ZBarcode_Encode_File, [:zint_symbol, :filename], :error_code, blocking: true)
|
40
|
+
|
41
|
+
# Output a previously encoded symbol to file `symbol->outfile`
|
42
|
+
attach_function(:ZBarcode_Print, [:zint_symbol, :rotate_angle], :error_code, blocking: true)
|
43
|
+
|
44
|
+
# Encode and output a symbol to file `symbol->outfile`
|
45
|
+
attach_function(:ZBarcode_Encode_and_Print, [:zint_symbol, :source, :length, :rotate_angle], :error_code, blocking: true)
|
46
|
+
|
47
|
+
# Encode a symbol using input data from file `filename` and output to file `symbol->outfile`
|
48
|
+
attach_function(:ZBarcode_Encode_File_and_Print, [:zint_symbol, :filename, :rotate_angle], :error_code, blocking: true)
|
49
|
+
|
50
|
+
# Output a previously encoded symbol to memory as raster (`symbol->bitmap`)
|
51
|
+
attach_function(:ZBarcode_Buffer, [:zint_symbol, :rotate_angle], :error_code, blocking: true)
|
52
|
+
|
53
|
+
# Encode and output a symbol to memory as raster (`symbol->bitmap`)
|
54
|
+
attach_function(:ZBarcode_Encode_and_Buffer, [:zint_symbol, :source, :length, :rotate_angle], :error_code, blocking: true)
|
55
|
+
|
56
|
+
# Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`)
|
57
|
+
attach_function(:ZBarcode_Encode_File_and_Buffer, [:zint_symbol, :filename, :rotate_angle], :error_code, blocking: true)
|
58
|
+
|
59
|
+
# Output a previously encoded symbol to memory as vector (`symbol->vector`)
|
60
|
+
attach_function(:ZBarcode_Buffer_Vector, [:zint_symbol, :rotate_angle], :error_code, blocking: true)
|
61
|
+
|
62
|
+
# Encode and output a symbol to memory as vector (`symbol->vector`)
|
63
|
+
attach_function(:ZBarcode_Encode_and_Buffer_Vector, [:zint_symbol, :source, :length, :rotate_angle], :error_code, blocking: true)
|
64
|
+
|
65
|
+
# Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`)
|
66
|
+
attach_function(:ZBarcode_Encode_File_and_Buffer_Vector, [:zint_symbol, :filename, :rotate_angle], :error_code, blocking: true)
|
67
|
+
|
68
|
+
# ********* Segment support *********
|
69
|
+
# int ZBarcode_Encode_Segs(struct zint_symbol *symbol,
|
70
|
+
# const struct zint_seg segs[], const int seg_count);
|
71
|
+
attach_function(:ZBarcode_Encode_Segs, [:zint_symbol, :pointer, :int], :error_code, blocking: true)
|
72
|
+
|
73
|
+
# int ZBarcode_Encode_Segs_and_Print(struct zint_symbol *symbol,
|
74
|
+
# const struct zint_seg segs[], const int seg_count, int rotate_angle);
|
75
|
+
attach_function(:ZBarcode_Encode_Segs_and_Print, [:zint_symbol, :pointer, :int, :rotate_angle], :error_code, blocking: true)
|
76
|
+
|
77
|
+
# int ZBarcode_Encode_Segs_and_Buffer(struct zint_symbol *symbol,
|
78
|
+
# const struct zint_seg segs[], const int seg_count, int rotate_angle);
|
79
|
+
attach_function(:ZBarcode_Encode_Segs_and_Buffer, [:zint_symbol, :pointer, :int, :rotate_angle], :error_code, blocking: true)
|
80
|
+
|
81
|
+
# int ZBarcode_Encode_Segs_and_Buffer_Vector(struct zint_symbol *symbol,
|
82
|
+
# const struct zint_seg segs[], const int seg_count, int rotate_angle);
|
83
|
+
attach_function(:ZBarcode_Encode_Segs_and_Buffer_Vector, [:zint_symbol, :pointer, :int, :rotate_angle], :error_code, blocking: true)
|
84
|
+
|
85
|
+
# Is `symbol_id` a recognized symbology?
|
86
|
+
attach_function(:ZBarcode_ValidID, [:symbol_id], :bool, blocking: true)
|
87
|
+
|
88
|
+
# Return the capability flags for symbology `symbol_id` that match `cap_flag`
|
89
|
+
attach_function(:ZBarcode_Cap, [:symbol_id, :cap_flag], :uint32, blocking: true)
|
90
|
+
|
91
|
+
# Return the version of Zint linked to
|
92
|
+
attach_function(:ZBarcode_Version, [], :int32, blocking: true)
|
93
|
+
|
94
|
+
# Raises specific error for API return code
|
95
|
+
#
|
96
|
+
# @param res [Symbol, Integer] API return code
|
97
|
+
# @param text [String] error text
|
98
|
+
# @raise [Error]
|
99
|
+
def self.raise_error(res, text)
|
100
|
+
klass = ERROR_CLASS_FOR_RESULT[res.is_a?(Symbol) ? Zint::ERRORS[res] : res]
|
101
|
+
raise klass, text
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
private_constant :Native
|
106
|
+
end
|
data/lib/zint/nve18.rb
ADDED
data/lib/zint/pdf417.rb
ADDED
data/lib/zint/pharma.rb
ADDED
data/lib/zint/planet.rb
ADDED
data/lib/zint/plessey.rb
ADDED
data/lib/zint/postnet.rb
ADDED
data/lib/zint/pzn.rb
ADDED
data/lib/zint/qr.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Zint
|
2
|
+
# QR Code
|
3
|
+
class Qr < Barcode
|
4
|
+
# ECC Levels
|
5
|
+
ECC_LEVEL_L = 1
|
6
|
+
ECC_LEVEL_M = 2
|
7
|
+
ECC_LEVEL_Q = 3
|
8
|
+
ECC_LEVEL_H = 4
|
9
|
+
|
10
|
+
# Current ECC level of QR code
|
11
|
+
attr_reader :ecc_level
|
12
|
+
|
13
|
+
def initialize(value: nil, input_file: nil, ecc_level: ECC_LEVEL_L, **kwargs)
|
14
|
+
super(value: value, input_file: input_file, symbology: Zint::BARCODE_QRCODE, **kwargs.merge(option_1: ecc_level))
|
15
|
+
@ecc_level = ecc_level
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/zint/rmqr.rb
ADDED
data/lib/zint/rss14.rb
ADDED
data/lib/zint/rssexp.rb
ADDED
data/lib/zint/rssltd.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Zint
|
2
|
+
module Structs
|
3
|
+
class Seg < FFI::Struct
|
4
|
+
# /* Segment for use with `raw_segs` and API `ZBarcode_Encode_Segs()` */
|
5
|
+
# struct zint_seg {
|
6
|
+
# unsigned char *source; /* Data to encode, or (`raw_segs`) data encoded */
|
7
|
+
# int length; /* Length of `source`. If 0 or negative, `source` must be NUL-terminated */
|
8
|
+
# int eci; /* Extended Channel Interpretation */
|
9
|
+
# };
|
10
|
+
|
11
|
+
layout :source, :pointer, # Data to encode, or (`raw_segs`) data encoded
|
12
|
+
:length, :int, # Length of `source`. If 0 or negative, `source` must be NUL-terminated
|
13
|
+
:eci, :int # Extended Channel Interpretation
|
14
|
+
|
15
|
+
# Data to encode, or (`raw_segs`) data encoded
|
16
|
+
def source
|
17
|
+
self[:source].read_bytes(self[:length])
|
18
|
+
end
|
19
|
+
|
20
|
+
# Extended Channel Interpretation
|
21
|
+
def eci
|
22
|
+
self[:eci]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Zint
|
2
|
+
module Structs
|
3
|
+
# Structured Append info - ignored unless `zint_structapp.count` is set to non-zero value
|
4
|
+
class Structapp < FFI::Struct
|
5
|
+
layout :index, :int, # Position in Structured Append sequence, 1-based. Must be <= `count`
|
6
|
+
:count, :int, # Number of symbols in Structured Append sequence. Set >= 2 to add SA Info
|
7
|
+
:id, [:char, 32] # Optional ID to distinguish sequence, ASCII, NUL-terminated unless max 32 long
|
8
|
+
|
9
|
+
# Position in Structured Append sequence, 1-based. Must be <= `count`
|
10
|
+
def index
|
11
|
+
self[:index]
|
12
|
+
end
|
13
|
+
|
14
|
+
# Number of symbols in Structured Append sequence. Set >= 2 to add SA Info
|
15
|
+
def count
|
16
|
+
self[:count]
|
17
|
+
end
|
18
|
+
|
19
|
+
# Optional ID to distinguish sequence, ASCII, NUL-terminated unless max 32 long
|
20
|
+
def id
|
21
|
+
self[:id]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Zint
|
2
|
+
module Structs
|
3
|
+
class Symbol < FFI::ManagedStruct
|
4
|
+
layout :symbology, :int, # Symbol to use (see BARCODE_XXX below)
|
5
|
+
:height, :float, # Barcode height in X-dimensions (ignored for fixed-width barcodes)
|
6
|
+
:scale, :float, # Scale factor when printing barcode, i.e. adjusts X-dimension. Default 1
|
7
|
+
:whitespace_width, :int, # Width in X-dimensions of whitespace to left & right of barcode
|
8
|
+
:whitespace_height, :int, # Height in X-dimensions of whitespace above & below the barcode
|
9
|
+
:border_width, :int, # Size of border in X-dimensions
|
10
|
+
:output_options, :int, # Various output parameters (bind, box etc, see below)
|
11
|
+
:fgcolour, [:char, 16], # Foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
|
12
|
+
:bgcolour, [:char, 16], # Background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
|
13
|
+
:fgcolor, :pointer, # Pointer to fgcolour (alternate spelling)
|
14
|
+
:bgcolor, :pointer, # Pointer to bgcolour (alternate spelling)
|
15
|
+
:outfile, [:char, 256], # Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if NO_PNG)
|
16
|
+
:primary, [:char, 128], # Primary message data (MaxiCode, Composite), NUL-terminated
|
17
|
+
:option_1, :int, # Symbol-specific options (see "../docs/manual.txt")
|
18
|
+
:option_2, :int, # Symbol-specific options
|
19
|
+
:option_3, :int, # Symbol-specific options
|
20
|
+
:show_hrt, :int, # Show (1) or hide (0) Human Readable Text (HRT). Default 1
|
21
|
+
:input_mode, :int, # Encoding of input data (see DATA_MODE etc below). Default DATA_MODE
|
22
|
+
:eci, :int, # Extended Channel Interpretation. Default 0 (none)
|
23
|
+
:dpmm, :float, # Resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
|
24
|
+
:dot_size, :float, # Size of dots used in BARCODE_DOTTY_MODE. Default 0.8
|
25
|
+
:text_gap, :float, # float text_gap; /* Gap between barcode and text (HRT) in X-dimensions. Default 1 */
|
26
|
+
:guard_descent, :float, # Height in X-dimensions that EAN/UPC guard bars descend. Default 5
|
27
|
+
:structapp, Structapp, # Structured Append info. Default structapp.count 0 (none)
|
28
|
+
:warn_level, :int, # Affects error/warning value returned by Zint API (see WARN_XXX below)
|
29
|
+
:debug, :int, # Debugging flags
|
30
|
+
:text, [:uchar, 256], # Human Readable Text (if any), UTF-8, NUL-terminated (output only)
|
31
|
+
:text_length, :int, # int text_length; /* Length of text in bytes (output only) */
|
32
|
+
:rows, :int, # Number of rows used by the symbol (output only)
|
33
|
+
:width, :int, # Width of the generated symbol (output only)
|
34
|
+
:encoded_data, [:uchar, 200 * 144], # Encoded data (output only). Allows for rows of 1152 modules
|
35
|
+
:row_height, [:float, 200], # Heights of rows (output only). Allows for 200 row DotCode
|
36
|
+
:errtxt, [:char, 100], # Error message if an error or warning occurs, NUL-terminated (output only)
|
37
|
+
:bitmap, :pointer, # Stored bitmap image (raster output only)
|
38
|
+
:bitmap_width, :int, # Width of bitmap image (raster output only)
|
39
|
+
:bitmap_height, :int, # Height of bitmap image (raster output only)
|
40
|
+
:alphamap, :pointer, # Array of alpha values used (raster output only)
|
41
|
+
:vector, Vector.by_ref, # Pointer to vector header (vector output only)
|
42
|
+
:memfile, :pointer, # unsigned char *memfile; /* Pointer to in-memory file buffer if BARCODE_MEMORY_FILE (output only) */
|
43
|
+
:memfile_size, :int # int memfile_size; /* Length of in-memory file buffer (output only) */
|
44
|
+
|
45
|
+
# Upcomming zint-2.16:
|
46
|
+
# struct zint_seg *raw_segs; /* Pointer to array of raw segs if BARCODE_RAW_TEXT (output only) */
|
47
|
+
# :raw_segs, Seg.by_ref,
|
48
|
+
# int raw_seg_count; /* Number of `raw_segs` (output only) */
|
49
|
+
# :raw_seg_count, :int
|
50
|
+
|
51
|
+
# @private
|
52
|
+
def self.release(ptr)
|
53
|
+
Native.ZBarcode_Delete(ptr)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Zint
|
2
|
+
module Structs
|
3
|
+
class Vector < FFI::Struct
|
4
|
+
layout :width, :float, # Width, height of barcode image (including text, whitespace)
|
5
|
+
:height, :float,
|
6
|
+
:rectangles, VectorRect.by_ref, # Pointer to first rectangle
|
7
|
+
:hexagons, VectorHexagon.by_ref, # Pointer to first hexagon
|
8
|
+
:strings, VectorString.by_ref, # Pointer to first string
|
9
|
+
:circles, VectorCircle.by_ref # Pointer to first circle
|
10
|
+
|
11
|
+
# Height of barcode image (including text, whitespace)
|
12
|
+
def height
|
13
|
+
self[:height]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Width of barcode image (including text, whitespace)
|
17
|
+
def width
|
18
|
+
self[:width]
|
19
|
+
end
|
20
|
+
|
21
|
+
# Calls the given block and passes a {VectorRect} object for each rectangle to be printed.
|
22
|
+
def each_rectangle(&block)
|
23
|
+
each_vector(:rectangles, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Calls the given block and passes a {VectorHexagon} object for each hexagon to be printed.
|
27
|
+
def each_hexagon(&block)
|
28
|
+
each_vector(:hexagons, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Calls the given block and passes a {VectorString} object for each text string to be printed.
|
32
|
+
def each_string(&block)
|
33
|
+
each_vector(:strings, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Calls the given block and passes a {VectorCircle} object for each circle to be printed.
|
37
|
+
def each_circle(&block)
|
38
|
+
each_vector(:circles, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
private def each_vector(attr)
|
42
|
+
return to_enum(:each_vector, attr) unless block_given?
|
43
|
+
|
44
|
+
o = self[attr]
|
45
|
+
until o.null?
|
46
|
+
# Avoid garbage collection of Vector (and hence Barcode) before Vector*, since all memory is freed by ZBarcode_Delete()
|
47
|
+
o.instance_variable_set(:@vector, self)
|
48
|
+
yield o
|
49
|
+
o = o[:next]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Zint
|
2
|
+
module Structs
|
3
|
+
class VectorCircle < FFI::Struct
|
4
|
+
layout :x, :float,
|
5
|
+
:y, :float,
|
6
|
+
:diameter, :float, # Circle diameter. Does not include width (if any)
|
7
|
+
:width, :float, # Width of circle perimeter (circumference). 0 for fill (disc)
|
8
|
+
:colour, :int, # Non-zero for draw with background colour (else draw with foreground colour)
|
9
|
+
:next, VectorCircle.by_ref # Pointer to next circle
|
10
|
+
|
11
|
+
# x position
|
12
|
+
def x
|
13
|
+
self[:x]
|
14
|
+
end
|
15
|
+
|
16
|
+
# y position
|
17
|
+
def y
|
18
|
+
self[:y]
|
19
|
+
end
|
20
|
+
|
21
|
+
# diameter
|
22
|
+
def diameter
|
23
|
+
self[:diameter]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Non-zero for draw with background colour
|
27
|
+
def colour
|
28
|
+
self[:colour]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|