ruby-zint-es 1.3.0

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.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.standard.yml +5 -0
  4. data/.yardopts +9 -0
  5. data/Gemfile +18 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +114 -0
  8. data/Rakefile +20 -0
  9. data/ext/ruby-zint/extconf.rb +86 -0
  10. data/lib/ruby-zint.rb +1 -0
  11. data/lib/zint/aus_post.rb +8 -0
  12. data/lib/zint/aus_redirect.rb +8 -0
  13. data/lib/zint/aus_reply.rb +8 -0
  14. data/lib/zint/aus_route.rb +8 -0
  15. data/lib/zint/azrune.rb +8 -0
  16. data/lib/zint/aztec.rb +8 -0
  17. data/lib/zint/barcode.rb +498 -0
  18. data/lib/zint/bc_412.rb +8 -0
  19. data/lib/zint/bitmap.rb +4 -0
  20. data/lib/zint/bitmap_pixel.rb +4 -0
  21. data/lib/zint/c25iata.rb +8 -0
  22. data/lib/zint/c25ind.rb +8 -0
  23. data/lib/zint/c25inter.rb +8 -0
  24. data/lib/zint/c25logic.rb +8 -0
  25. data/lib/zint/c25matrix.rb +8 -0
  26. data/lib/zint/c25standard.rb +8 -0
  27. data/lib/zint/cep_net.rb +8 -0
  28. data/lib/zint/channel.rb +8 -0
  29. data/lib/zint/codabar.rb +8 -0
  30. data/lib/zint/codablock_f.rb +8 -0
  31. data/lib/zint/code11.rb +8 -0
  32. data/lib/zint/code128.rb +8 -0
  33. data/lib/zint/code128ab.rb +8 -0
  34. data/lib/zint/code128b.rb +5 -0
  35. data/lib/zint/code16k.rb +8 -0
  36. data/lib/zint/code32.rb +8 -0
  37. data/lib/zint/code39.rb +8 -0
  38. data/lib/zint/code49.rb +8 -0
  39. data/lib/zint/code93.rb +8 -0
  40. data/lib/zint/code_one.rb +8 -0
  41. data/lib/zint/constants/capability_flags.rb +21 -0
  42. data/lib/zint/constants/debug_flags.rb +9 -0
  43. data/lib/zint/constants/errors.rb +19 -0
  44. data/lib/zint/constants/input_data_types.rb +15 -0
  45. data/lib/zint/constants/output_options.rb +21 -0
  46. data/lib/zint/constants/specific_options.rb +12 -0
  47. data/lib/zint/constants/symbologies.rb +137 -0
  48. data/lib/zint/constants/warn_levels.rb +9 -0
  49. data/lib/zint/constants/warnings.rb +12 -0
  50. data/lib/zint/daft.rb +8 -0
  51. data/lib/zint/data_matrix.rb +19 -0
  52. data/lib/zint/dbarexp.rb +8 -0
  53. data/lib/zint/dbarexpstk.rb +8 -0
  54. data/lib/zint/dbarltd.rb +8 -0
  55. data/lib/zint/dbaromn.rb +8 -0
  56. data/lib/zint/dbaromnstk.rb +8 -0
  57. data/lib/zint/dbarstk.rb +8 -0
  58. data/lib/zint/dependencies.rb +7 -0
  59. data/lib/zint/dot_code.rb +8 -0
  60. data/lib/zint/dpd.rb +8 -0
  61. data/lib/zint/dpident.rb +8 -0
  62. data/lib/zint/dpleit.rb +8 -0
  63. data/lib/zint/ean128.rb +8 -0
  64. data/lib/zint/ean14.rb +8 -0
  65. data/lib/zint/eanx.rb +8 -0
  66. data/lib/zint/eanxchk.rb +8 -0
  67. data/lib/zint/excode39.rb +8 -0
  68. data/lib/zint/fim.rb +8 -0
  69. data/lib/zint/flat.rb +8 -0
  70. data/lib/zint/grid_matrix.rb +8 -0
  71. data/lib/zint/gs1_128.rb +10 -0
  72. data/lib/zint/hanxin.rb +8 -0
  73. data/lib/zint/hibc128.rb +8 -0
  74. data/lib/zint/hibc39.rb +8 -0
  75. data/lib/zint/hibcaztec.rb +8 -0
  76. data/lib/zint/hibcblockf.rb +8 -0
  77. data/lib/zint/hibcdm.rb +8 -0
  78. data/lib/zint/hibcmicpdf.rb +8 -0
  79. data/lib/zint/hibcpdf.rb +8 -0
  80. data/lib/zint/hibcqr.rb +8 -0
  81. data/lib/zint/isbnx.rb +8 -0
  82. data/lib/zint/itf14.rb +8 -0
  83. data/lib/zint/japan_post.rb +8 -0
  84. data/lib/zint/kix.rb +8 -0
  85. data/lib/zint/korea_post.rb +8 -0
  86. data/lib/zint/logmars.rb +8 -0
  87. data/lib/zint/mailmark.rb +8 -0
  88. data/lib/zint/mailmark_2d.rb +8 -0
  89. data/lib/zint/mailmark_4s.rb +8 -0
  90. data/lib/zint/maxi_code.rb +8 -0
  91. data/lib/zint/micro_pdf417.rb +8 -0
  92. data/lib/zint/micro_qr.rb +8 -0
  93. data/lib/zint/msiplessey.rb +8 -0
  94. data/lib/zint/native.rb +87 -0
  95. data/lib/zint/nve18.rb +8 -0
  96. data/lib/zint/one_code.rb +8 -0
  97. data/lib/zint/pdf417.rb +8 -0
  98. data/lib/zint/pdf417comp.rb +8 -0
  99. data/lib/zint/pdf417trunc.rb +8 -0
  100. data/lib/zint/pharma.rb +8 -0
  101. data/lib/zint/pharmatwo.rb +8 -0
  102. data/lib/zint/planet.rb +8 -0
  103. data/lib/zint/plessey.rb +8 -0
  104. data/lib/zint/postnet.rb +8 -0
  105. data/lib/zint/pzn.rb +8 -0
  106. data/lib/zint/qr.rb +18 -0
  107. data/lib/zint/rmqr.rb +8 -0
  108. data/lib/zint/rss14.rb +8 -0
  109. data/lib/zint/rss14stack.rb +8 -0
  110. data/lib/zint/rss14stackomni.rb +8 -0
  111. data/lib/zint/rssexp.rb +8 -0
  112. data/lib/zint/rssexpstack.rb +8 -0
  113. data/lib/zint/rssltd.rb +8 -0
  114. data/lib/zint/structs/structapp.rb +25 -0
  115. data/lib/zint/structs/symbol.rb +49 -0
  116. data/lib/zint/structs/vector.rb +54 -0
  117. data/lib/zint/structs/vector_circle.rb +32 -0
  118. data/lib/zint/structs/vector_hexagon.rb +31 -0
  119. data/lib/zint/structs/vector_rect.rb +37 -0
  120. data/lib/zint/structs/vector_string.rb +50 -0
  121. data/lib/zint/telepen.rb +8 -0
  122. data/lib/zint/telepennum.rb +8 -0
  123. data/lib/zint/ultra.rb +8 -0
  124. data/lib/zint/upc_a.rb +8 -0
  125. data/lib/zint/upc_a_chk.rb +8 -0
  126. data/lib/zint/upc_e.rb +8 -0
  127. data/lib/zint/upc_e_chk.rb +8 -0
  128. data/lib/zint/upnqr.rb +8 -0
  129. data/lib/zint/upu_s10.rb +8 -0
  130. data/lib/zint/uspsimail.rb +8 -0
  131. data/lib/zint/version.rb +3 -0
  132. data/lib/zint/vin.rb +8 -0
  133. data/lib/zint/zint_recipe.rb +27 -0
  134. data/lib/zint.rb +168 -0
  135. data/ports/archives/zint-2.12.0-src.tar.gz +0 -0
  136. data/ruby-zint.gemspec +40 -0
  137. metadata +326 -0
@@ -0,0 +1,498 @@
1
+ module Zint
2
+ # Base class to represent the barcode
3
+ #
4
+ # @example Create new barcode
5
+ # barcode = Zint::Barcode.new(value: "Test", symbology: Zint::BARCODE_QRCODE, option_1: 1)
6
+ # barcode.to_file(path: "qr.png")
7
+ class Barcode
8
+ include Native
9
+
10
+ class AlreadyGenerated < Error; end
11
+
12
+ # @return [String, NilClass] Content of the barcode
13
+ attr_accessor :value
14
+ # @return [String, NilClass] Path to input file with content of the barcode
15
+ attr_accessor :input_file
16
+
17
+ # @param value [String, NilClass] Content of the barcode
18
+ # @param input_file [String, NilClass] Path to input file with content of the barcode
19
+ # @param symbology [Integer] Type of barcode
20
+ # @param kwargs [Hash] Specific options for zint symbol (height, scale, ...)
21
+ def initialize(value: nil, input_file: nil, symbology: Zint::BARCODE_CODE128, **kwargs)
22
+ raise ArgumentError, "value or input_file must be given!" if value&.empty? && input_file&.empty?
23
+ raise ArgumentError, "input_file not found!" if input_file && !File.exist?(input_file)
24
+
25
+ @zint_symbol = Native.ZBarcode_Create
26
+ self.symbology = symbology
27
+ kwargs.each do |k, v|
28
+ send("#{k}=", v)
29
+ end
30
+
31
+ @value = value
32
+ @input_file = input_file
33
+ end
34
+
35
+ # Exports barcode to file
36
+ #
37
+ # @param path [String] Path to export file.
38
+ # Contains the name of the file to output a resulting barcode symbol to.
39
+ # Must end in .png, .gif, .bmp, .emf, .eps, .pcx, .svg, .tif or .txt
40
+ # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
41
+ def to_file(path:, rotate_angle: 0)
42
+ unless outfile == 'out.png'
43
+ raise AlreadyGenerated, "to_file was already executed"
44
+ end
45
+ @zint_symbol[:outfile] = path
46
+
47
+ if input_file
48
+ call_function(:ZBarcode_Encode_File_and_Print, @zint_symbol, input_file, rotate_angle)
49
+ else
50
+ call_function(:ZBarcode_Encode_and_Print, @zint_symbol, value, 0, rotate_angle)
51
+ end
52
+ end
53
+
54
+ # Exports barcode to memory file
55
+ #
56
+ # @param extension [String] Extension exported memory file
57
+ # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
58
+ # @return [String] Exported memory file
59
+ def to_memory_file(extension: ".png", rotate_angle: 0)
60
+ require "tempfile"
61
+ file = Tempfile.new(["zint", extension])
62
+
63
+ to_file(path: file.path, rotate_angle: rotate_angle)
64
+
65
+ file.rewind
66
+ buffer = file.read
67
+ file.close
68
+ file.unlink
69
+
70
+ buffer
71
+ end
72
+
73
+ # Exports barcode to buffer
74
+ #
75
+ # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
76
+ # @return [String] Exported barcode buffer
77
+ def to_buffer(rotate_angle: 0)
78
+ unless @zint_symbol[:bitmap].null?
79
+ raise AlreadyGenerated, "to_vector was already executed"
80
+ end
81
+ @zint_symbol[:output_options] = Zint::OUT_BUFFER_INTERMEDIATE
82
+
83
+ if input_file
84
+ call_function(:ZBarcode_Encode_File_and_Buffer, @zint_symbol, input_file, rotate_angle)
85
+ else
86
+ call_function(:ZBarcode_Encode_and_Buffer, @zint_symbol, value, 0, rotate_angle)
87
+ end
88
+
89
+ @zint_symbol[:bitmap].read_bytes((@zint_symbol[:bitmap_width] * @zint_symbol[:bitmap_height]))
90
+ end
91
+
92
+ # Exports barcode to buffer
93
+ #
94
+ # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
95
+ # @return [Zint::Bitmap] Exported bitmap
96
+ def to_bitmap(rotate_angle: 0)
97
+ zint_bitmap = to_buffer(rotate_angle: rotate_angle)
98
+
99
+ pixels = []
100
+ @zint_symbol[:bitmap_height].times do |row|
101
+ @zint_symbol[:bitmap_width].times do |column|
102
+ pixels << BitmapPixel.new(column, row, zint_bitmap[pixels.size])
103
+ end
104
+ end
105
+
106
+ Bitmap.new(@zint_symbol[:bitmap_width], @zint_symbol[:bitmap_height], pixels)
107
+ end
108
+
109
+ # Exports barcode as Zint vector
110
+ #
111
+ # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
112
+ # @return [Zint::Structs::Vector] Vector data of barcode
113
+ def to_vector(rotate_angle: 0)
114
+ unless @zint_symbol[:vector].pointer.null?
115
+ raise AlreadyGenerated, "to_vector was already executed"
116
+ end
117
+ if input_file
118
+ call_function(:ZBarcode_Encode_File_and_Buffer_Vector, @zint_symbol, input_file, rotate_angle)
119
+ else
120
+ call_function(:ZBarcode_Encode_and_Buffer_Vector, @zint_symbol, value, 0, rotate_angle)
121
+ end
122
+
123
+ v = @zint_symbol[:vector]
124
+ # Avoid garbage collection of Symbol before Vector, since the Vector is also freed by ZBarcode_Delete()
125
+ v.instance_variable_set(:@symbol, @zint_symbol)
126
+ v
127
+ end
128
+
129
+ # Free barcode and all memory associated with it.
130
+ #
131
+ # Note: This method is dangerous insofar, that previously exported vectors (by #to_vector ) are no longer usable and any access to them will result in a segfault.
132
+ # It is better to not call this method and leave cleaning up to the garbage collector.
133
+ def free
134
+ @zint_symbol.pointer.free
135
+ end
136
+
137
+ # Attributes
138
+
139
+ # Gets type of barcode
140
+ def symbology
141
+ @zint_symbol[:symbology]
142
+ end
143
+
144
+ # Sets symbol to use (see BARCODE_XXX below)
145
+ #
146
+ # @param type [Integer] Type of barcode
147
+ def symbology=(type)
148
+ @zint_symbol[:symbology] = type
149
+ end
150
+
151
+ # Gets height of barcode
152
+ def height
153
+ @zint_symbol[:height]
154
+ end
155
+
156
+ # Sets height in X-dimensions (ignored for fixed-width barcodes)
157
+ #
158
+ # @param height [Float] Height of barcode
159
+ def height=(height)
160
+ @zint_symbol[:height] = height
161
+ end
162
+
163
+ # Gets scale factor of barcode
164
+ def scale
165
+ @zint_symbol[:scale]
166
+ end
167
+
168
+ # Sets scale factor when printing barcode
169
+ #
170
+ # @param scale [Float] Scale of barcode
171
+ def scale=(scale)
172
+ @zint_symbol[:scale] = scale
173
+ end
174
+
175
+ # Gets width in X-dimensions of whitespace to left & right of barcode
176
+ def whitespace_width
177
+ @zint_symbol[:whitespace_width]
178
+ end
179
+
180
+ # Sets width in X-dimensions of whitespace to left & right of barcode
181
+ #
182
+ # @param whitespace_width [Integer] Whitespace width of barcode
183
+ def whitespace_width=(whitespace_width)
184
+ @zint_symbol[:whitespace_width] = whitespace_width
185
+ end
186
+
187
+ # Gets height in X-dimensions of whitespace above & below the barcode
188
+ def whitespace_height
189
+ @zint_symbol[:whitespace_height]
190
+ end
191
+
192
+ # Sets height in X-dimensions of whitespace above & below the barcode
193
+ #
194
+ # @param whitespace_height [Integer] Whitespace height of barcode
195
+ def whitespace_height=(whitespace_height)
196
+ @zint_symbol[:whitespace_height] = whitespace_height
197
+ end
198
+
199
+ # Gets size of border in X-dimensions
200
+ def border_width
201
+ @zint_symbol[:border_width]
202
+ end
203
+
204
+ # Sets size of border in X-dimensions
205
+ #
206
+ # @param border_width [Integer] Border width of barcode
207
+ def border_width=(border_width)
208
+ @zint_symbol[:border_width] = border_width
209
+ end
210
+
211
+ # Gets output options of barcode
212
+ def output_options
213
+ @zint_symbol[:output_options]
214
+ end
215
+
216
+ # Set various output parameters (bind, box etc, see below) of barcode
217
+ #
218
+ # @param output_options [Integer] Output options of barcode
219
+ def output_options=(output_options)
220
+ @zint_symbol[:output_options] = output_options
221
+ end
222
+
223
+ # Gets foreground colour of barcode
224
+ def fgcolour
225
+ @zint_symbol[:fgcolour].to_s
226
+ end
227
+
228
+ # Sets foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
229
+ #
230
+ # @param fgcolour [String] Foreground colour of barcode
231
+ def fgcolour=(fgcolour)
232
+ @zint_symbol[:fgcolour] = fgcolour
233
+ end
234
+
235
+ # Gets background colour of barcode
236
+ def bgcolour
237
+ @zint_symbol[:bgcolour].to_s
238
+ end
239
+
240
+ # Sets background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
241
+ #
242
+ # @param bgcolour [String] Background color of barcode
243
+ def bgcolour=(bgcolour)
244
+ @zint_symbol[:bgcolour] = bgcolour
245
+ end
246
+
247
+ # Contains the name of the file to output a resulting barcode symbol to.
248
+ #
249
+ # Must end in .png, .gif, .bmp, .emf, .eps, .pcx, .svg, .tif or .txt
250
+ def outfile
251
+ @zint_symbol[:outfile].to_s
252
+ end
253
+
254
+ # Gets option 1 of barcode
255
+ def option_1
256
+ @zint_symbol[:option_1]
257
+ end
258
+
259
+ # Sets option 1 (symbol-specific options (see "../docs/manual.txt"))
260
+ #
261
+ # @param option_1 [Integer] Option 1 of barcode
262
+ def option_1=(option_1)
263
+ @zint_symbol[:option_1] = option_1
264
+ end
265
+
266
+ # Gets option 2 of barcode
267
+ def option_2
268
+ @zint_symbol[:option_2]
269
+ end
270
+
271
+ # Sets option 2 (symbol-specific options) of barcode
272
+ #
273
+ # @param option_2 [Integer] Option 2 of barcode
274
+ def option_2=(option_2)
275
+ @zint_symbol[:option_2] = option_2
276
+ end
277
+
278
+ # Gets option 3 of barcode
279
+ def option_3
280
+ @zint_symbol[:option_3]
281
+ end
282
+
283
+ # Sets option 3 (symbol-specific options) of barcode
284
+ #
285
+ # @param option_3 [Integer] Option 3 of barcode
286
+ def option_3=(option_3)
287
+ @zint_symbol[:option_3] = option_3
288
+ end
289
+
290
+ # Gets show_hrt of barcode
291
+ def show_hrt
292
+ @zint_symbol[:show_hrt]
293
+ end
294
+
295
+ # Sets show_hrt of barcode
296
+ # show = 1 or hide = 0 Human Readable Text. Default is show (1)
297
+ #
298
+ # @param show_hrt [Integer] show_hrt of barcode
299
+ def show_hrt=(show_hrt)
300
+ @zint_symbol[:show_hrt] = show_hrt
301
+ end
302
+
303
+ # Gets font size of barcode
304
+ def fontsize
305
+ @zint_symbol[:fontsize]
306
+ end
307
+
308
+ # Sets font size of barcode (Unused)
309
+ #
310
+ # @param fontsize [Integer] Font size of barcode
311
+ def fontsize=(fontsize)
312
+ @zint_symbol[:fontsize] = fontsize
313
+ end
314
+
315
+ # Gets input mode of barcode
316
+ def input_mode
317
+ @zint_symbol[:input_mode]
318
+ end
319
+
320
+ # Sets encoding of input data (see DATA_MODE etc below). Default DATA_MODE
321
+ #
322
+ # @param input_mode [Integer] Input mode of barcode
323
+ def input_mode=(input_mode)
324
+ @zint_symbol[:input_mode] = input_mode
325
+ end
326
+
327
+ # Gets ECI of barcode
328
+ def eci
329
+ @zint_symbol[:eci]
330
+ end
331
+
332
+ # Sets extended Channel Interpretation. Default 0 (none)
333
+ #
334
+ # @param eci [Integer] ECI of barcode
335
+ def eci=(eci)
336
+ @zint_symbol[:eci] = eci
337
+ end
338
+
339
+ # Gets resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
340
+ def dpmm
341
+ @zint_symbol[:dpmm]
342
+ end
343
+
344
+ # Sets resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
345
+ #
346
+ # @param dpmm [Float] Resolution of output in dots per mm
347
+ def dpmm=(dpmm)
348
+ @zint_symbol[:dpmm] = dpmm
349
+ end
350
+
351
+ # Gets height in X-dimensions that EAN/UPC guard bars descend. Default 5
352
+ def guard_descent
353
+ @zint_symbol[:guard_descent]
354
+ end
355
+
356
+ # Sets height in X-dimensions that EAN/UPC guard bars descend. Default 5
357
+ #
358
+ # @param guard_descent [Float] Height in X-dimensions that EAN/UPC guard bars descend
359
+ def guard_descent=(guard_descent)
360
+ @zint_symbol[:guard_descent] = guard_descent
361
+ end
362
+
363
+ # Gets structured append info. Default structapp.count 0 (none)
364
+ def structapp
365
+ @zint_symbol[:structapp]
366
+ end
367
+
368
+ # Sets structured append info. Default structapp.count 0 (none)
369
+ #
370
+ # @param structapp [Structs::Structapp] Structured append info
371
+ def structapp=(structapp)
372
+ @zint_symbol[:structapp] = structapp
373
+ end
374
+
375
+ # Human Readable Text, which usually consists of input data plus one more check digit. Uses UTF-8 formatting.
376
+ def text
377
+ @zint_symbol[:text].to_s.force_encoding(Encoding::UTF_8)
378
+ end
379
+
380
+ # Sets Human Readable Text (if any), UTF-8, NUL-terminated (output only) of barcode
381
+ #
382
+ # @param text [String] Text of barcode
383
+ def text=(text)
384
+ @zint_symbol[:text] = text
385
+ end
386
+
387
+ # Gets rows of barcode
388
+ def rows
389
+ @zint_symbol[:rows]
390
+ end
391
+
392
+ # Gets width of barcode
393
+ def width
394
+ @zint_symbol[:width]
395
+ end
396
+
397
+ # Gets primary message data for more complex symbols
398
+ def primary
399
+ @zint_symbol[:primary].to_s
400
+ end
401
+
402
+ # Sets primary message data (MaxiCode, Composite), NUL-terminated of barcode
403
+ #
404
+ # @param primary [String] Primary of barcode
405
+ def primary=(primary)
406
+ @zint_symbol[:primary] = primary
407
+ end
408
+
409
+ # Gets encoded data of barcode
410
+ def encoded_data
411
+ @zint_symbol[:encoded_data]
412
+ end
413
+
414
+ # Sets encoded data (output only). Allows for rows of 1144 modules of barcode
415
+ #
416
+ # @param encoded_data [String] Encoded data of barcode
417
+ def encoded_data=(encoded_data)
418
+ @zint_symbol[:encoded_data] = encoded_data
419
+ end
420
+
421
+ # Gets row height of barcode
422
+ def row_height
423
+ @zint_symbol[:row_height]
424
+ end
425
+
426
+ # Gets error message in the event that an error occurred
427
+ def errtxt
428
+ @zint_symbol[:errtxt].to_s.force_encoding(Encoding::UTF_8)
429
+ end
430
+
431
+ # Gets bitmap width of barcode
432
+ def bitmap_width
433
+ @zint_symbol[:bitmap_width]
434
+ end
435
+
436
+ # Gets bitmap height of barcode
437
+ def bitmap_height
438
+ @zint_symbol[:bitmap_height]
439
+ end
440
+
441
+ # Gets bitmap byte length of barcode
442
+ def bitmap_byte_length
443
+ @zint_symbol[:bitmap_byte_length]
444
+ end
445
+
446
+ # Gets dot size of barcode
447
+ def dot_size
448
+ @zint_symbol[:dot_size]
449
+ end
450
+
451
+ # Sets size of dots used in BARCODE_DOTTY_MODE
452
+ #
453
+ # @param dot_size [Float] Dot size of barcode
454
+ def dot_size=(dot_size)
455
+ @zint_symbol[:dot_size] = dot_size
456
+ end
457
+
458
+ # Gets debugging flags
459
+ def debug
460
+ @zint_symbol[:debug]
461
+ end
462
+
463
+ # Sets debugging flags
464
+ #
465
+ # @param debug [Integer] Debug level of barcode
466
+ def debug=(debug)
467
+ @zint_symbol[:debug] = debug
468
+ end
469
+
470
+ # Gets warn level of barcode
471
+ def warn_level
472
+ @zint_symbol[:warn_level]
473
+ end
474
+
475
+ # Sets warn level (affects error/warning value returned by Zint API (see WARN_XXX below)) of barcode
476
+ #
477
+ # @param warn_level [Integer] Warn level of barcode
478
+ def warn_level=(warn_level)
479
+ @zint_symbol[:warn_level] = warn_level
480
+ end
481
+
482
+ private
483
+
484
+ def reset_symbol
485
+ call_function(:ZBarcode_Clear, @zint_symbol)
486
+ end
487
+
488
+ def call_function(function_name, *args)
489
+ error_code = Native.send(function_name.to_sym, *args)
490
+
491
+ if Zint::ERRORS[error_code]
492
+ Native.raise_error(error_code, @zint_symbol[:errtxt])
493
+ end
494
+
495
+ error_code
496
+ end
497
+ end
498
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # IBM BC412 (SEMI T1-95)
3
+ class Bc412 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_BC412, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module Zint
2
+ # A class to represents a pixel from the bitmap
3
+ Bitmap = Struct.new(:width, :height, :pixels)
4
+ end
@@ -0,0 +1,4 @@
1
+ module Zint
2
+ # A class to represents a pixel from the bitmap
3
+ BitmapPixel = Struct.new(:x, :y, :colour)
4
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # 2 of 5 IATA
3
+ class C25iata < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_C25IATA, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # 2 of 5 Industrial
3
+ class C25ind < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_C25IND, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # 2 of 5 Interleaved
3
+ class C25inter < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_C25INTER, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # 2 of 5 Data Logic
3
+ class C25logic < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_C25LOGIC, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Legacy
3
+ class C25matrix < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_C25MATRIX, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # 2 of 5 Standard (Matrix)
3
+ class C25standard < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_C25STANDARD, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Brazilian CEPNet Postal Code
3
+ class CepNet < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CEPNET, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Channel Code
3
+ class Channel < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CHANNEL, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Codabar
3
+ class Codabar < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODABAR, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Codablock-F
3
+ class CodablockF < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODABLOCKF, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Code 11
3
+ class Code11 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODE11, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Code 128
3
+ class Code128 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODE128, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Code 128 (Suppress Code Set C)
3
+ class Code128AB < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODE128AB, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Zint
2
+ # Legacy
3
+ class Code128B < Code128AB
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Code 16k
3
+ class Code16k < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODE16K, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Code 32
3
+ class Code32 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODE32, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Code 39
3
+ class Code39 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODE39, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Code 49
3
+ class Code49 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODE49, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Code 93
3
+ class Code93 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_CODE93, **kwargs)
6
+ end
7
+ end
8
+ end