Rdmtx 0.2.2 → 0.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.
- checksums.yaml +7 -0
- data/ext/rdmtx/Rdmtx.c +74 -13
- metadata +13 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e874121a53296bf28bd6af2c3010f1077145005
|
4
|
+
data.tar.gz: 691f2663d354cd6a350470df612a8dc90b18eedc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6232a2b3881548515207fd8d4077ff7df5d7b3b0037a2b907170994fd591da348c1fecf1938a5b383c50b2737ab041b23a7a1552def288410215e241d1497ca
|
7
|
+
data.tar.gz: 39df386faaeb514c0dc777af1f15cbc0cf14bcf8853976b1458e6d237d9c94c876b9ed535110f51e1965815813b36ec6259a725b5a5ec6176ba13b2af7e15964
|
data/ext/rdmtx/Rdmtx.c
CHANGED
@@ -49,6 +49,7 @@ static VALUE rdmtx_decode(VALUE self, VALUE image /* Image from RMagick (Magick:
|
|
49
49
|
DmtxDecode * decode = dmtxDecodeCreate(dmtxImage, 1);
|
50
50
|
|
51
51
|
DmtxRegion * region;
|
52
|
+
DmtxMessage * message;
|
52
53
|
|
53
54
|
int intTimeout = NUM2INT(timeout);
|
54
55
|
DmtxTime dmtxTimeout = dmtxTimeAdd(dmtxTimeNow(), intTimeout);
|
@@ -63,7 +64,7 @@ static VALUE rdmtx_decode(VALUE self, VALUE image /* Image from RMagick (Magick:
|
|
63
64
|
if (region == NULL )
|
64
65
|
break;
|
65
66
|
|
66
|
-
|
67
|
+
message = dmtxDecodeMatrixRegion(decode, region, DmtxUndefined);
|
67
68
|
if (message != NULL) {
|
68
69
|
VALUE outputString = rb_str_new2((char *)message->output);
|
69
70
|
rb_ary_push(results, outputString);
|
@@ -79,17 +80,42 @@ static VALUE rdmtx_decode(VALUE self, VALUE image /* Image from RMagick (Magick:
|
|
79
80
|
return results;
|
80
81
|
}
|
81
82
|
|
82
|
-
static VALUE rdmtx_encode(
|
83
|
+
static VALUE rdmtx_encode(int argc, VALUE * argv, VALUE self) {
|
84
|
+
|
85
|
+
VALUE string, margin, module, size;
|
86
|
+
VALUE safeString;
|
87
|
+
int safeMargin, safeModule, safeSize;
|
88
|
+
DmtxEncode * enc;
|
89
|
+
int width;
|
90
|
+
int height;
|
91
|
+
VALUE magickImageClass;
|
92
|
+
VALUE outputImage;
|
93
|
+
|
94
|
+
rb_scan_args(argc, argv, "13", &string,
|
95
|
+
&margin, &module, &size);
|
96
|
+
|
97
|
+
safeString = StringValue(string);
|
98
|
+
if(margin == Qnil) {
|
99
|
+
safeMargin = 5;
|
100
|
+
} else {
|
101
|
+
safeMargin = NUM2INT(margin);
|
102
|
+
}
|
103
|
+
if(module == Qnil) {
|
104
|
+
safeModule = 5;
|
105
|
+
} else {
|
106
|
+
safeMargin = NUM2INT(module);
|
107
|
+
}
|
108
|
+
if(size == Qnil) {
|
109
|
+
safeSize = DmtxSymbolSquareAuto;
|
110
|
+
} else {
|
111
|
+
safeSize = NUM2INT(size);
|
112
|
+
}
|
83
113
|
|
84
114
|
/* Create and initialize libdmtx structures */
|
85
|
-
|
86
|
-
|
87
|
-
VALUE safeString = StringValue(string);
|
88
|
-
int safeMargin = NUM2INT(margin);
|
89
|
-
int safeModule = NUM2INT(module);
|
115
|
+
enc = dmtxEncodeCreate();
|
90
116
|
|
91
117
|
dmtxEncodeSetProp(enc, DmtxPropPixelPacking, DmtxPack24bppRGB);
|
92
|
-
dmtxEncodeSetProp(enc, DmtxPropSizeRequest,
|
118
|
+
dmtxEncodeSetProp(enc, DmtxPropSizeRequest, safeSize);
|
93
119
|
|
94
120
|
dmtxEncodeSetProp(enc, DmtxPropMarginSize, safeMargin);
|
95
121
|
dmtxEncodeSetProp(enc, DmtxPropModuleSize, safeModule);
|
@@ -102,11 +128,11 @@ static VALUE rdmtx_encode(VALUE self, VALUE string, VALUE margin, VALUE module)
|
|
102
128
|
return Qnil;
|
103
129
|
}
|
104
130
|
|
105
|
-
|
106
|
-
|
131
|
+
width = dmtxImageGetProp(enc->image, DmtxPropWidth);
|
132
|
+
height = dmtxImageGetProp(enc->image, DmtxPropHeight);
|
107
133
|
|
108
|
-
|
109
|
-
|
134
|
+
magickImageClass = rb_path2class("Magick::Image");
|
135
|
+
outputImage = rb_funcall(magickImageClass, rb_intern("new"), 2, INT2NUM(width), INT2NUM(height));
|
110
136
|
|
111
137
|
rb_funcall(outputImage, rb_intern("import_pixels"), 7,
|
112
138
|
INT2NUM(0),
|
@@ -129,5 +155,40 @@ void Init_Rdmtx() {
|
|
129
155
|
cRdmtx = rb_define_class("Rdmtx", rb_cObject);
|
130
156
|
rb_define_method(cRdmtx, "initialize", rdmtx_init, 0);
|
131
157
|
rb_define_method(cRdmtx, "decode", rdmtx_decode, 2);
|
132
|
-
rb_define_method(cRdmtx, "encode", rdmtx_encode,
|
158
|
+
rb_define_method(cRdmtx, "encode", rdmtx_encode, -1);
|
159
|
+
|
160
|
+
rb_define_global_const("DmtxSymbolRectAuto", INT2FIX(DmtxSymbolRectAuto));
|
161
|
+
rb_define_global_const("DmtxSymbolSquareAuto", INT2FIX(DmtxSymbolSquareAuto));
|
162
|
+
rb_define_global_const("DmtxSymbolShapeAuto", INT2FIX(DmtxSymbolShapeAuto));
|
163
|
+
|
164
|
+
rb_define_global_const("DmtxSymbol10x10", INT2FIX(DmtxSymbol10x10));
|
165
|
+
rb_define_global_const("DmtxSymbol12x12", INT2FIX(DmtxSymbol12x12));
|
166
|
+
rb_define_global_const("DmtxSymbol14x14", INT2FIX(DmtxSymbol14x14));
|
167
|
+
rb_define_global_const("DmtxSymbol16x16", INT2FIX(DmtxSymbol16x16));
|
168
|
+
rb_define_global_const("DmtxSymbol18x18", INT2FIX(DmtxSymbol18x18));
|
169
|
+
rb_define_global_const("DmtxSymbol20x20", INT2FIX(DmtxSymbol20x20));
|
170
|
+
rb_define_global_const("DmtxSymbol22x22", INT2FIX(DmtxSymbol22x22));
|
171
|
+
rb_define_global_const("DmtxSymbol24x24", INT2FIX(DmtxSymbol24x24));
|
172
|
+
rb_define_global_const("DmtxSymbol26x26", INT2FIX(DmtxSymbol26x26));
|
173
|
+
rb_define_global_const("DmtxSymbol32x32", INT2FIX(DmtxSymbol32x32));
|
174
|
+
rb_define_global_const("DmtxSymbol36x36", INT2FIX(DmtxSymbol36x36));
|
175
|
+
rb_define_global_const("DmtxSymbol40x40", INT2FIX(DmtxSymbol40x40));
|
176
|
+
rb_define_global_const("DmtxSymbol44x44", INT2FIX(DmtxSymbol44x44));
|
177
|
+
rb_define_global_const("DmtxSymbol48x48", INT2FIX(DmtxSymbol48x48));
|
178
|
+
rb_define_global_const("DmtxSymbol52x52", INT2FIX(DmtxSymbol52x52));
|
179
|
+
rb_define_global_const("DmtxSymbol64x64", INT2FIX(DmtxSymbol64x64));
|
180
|
+
rb_define_global_const("DmtxSymbol72x72", INT2FIX(DmtxSymbol72x72));
|
181
|
+
rb_define_global_const("DmtxSymbol80x80", INT2FIX(DmtxSymbol80x80));
|
182
|
+
rb_define_global_const("DmtxSymbol88x88", INT2FIX(DmtxSymbol88x88));
|
183
|
+
rb_define_global_const("DmtxSymbol96x96", INT2FIX(DmtxSymbol96x96));
|
184
|
+
rb_define_global_const("DmtxSymbol104x104", INT2FIX(DmtxSymbol104x104));
|
185
|
+
rb_define_global_const("DmtxSymbol120x120", INT2FIX(DmtxSymbol120x120));
|
186
|
+
rb_define_global_const("DmtxSymbol132x132", INT2FIX(DmtxSymbol132x132));
|
187
|
+
rb_define_global_const("DmtxSymbol144x144", INT2FIX(DmtxSymbol144x144));
|
188
|
+
rb_define_global_const("DmtxSymbol8x18", INT2FIX(DmtxSymbol8x18));
|
189
|
+
rb_define_global_const("DmtxSymbol8x32", INT2FIX(DmtxSymbol8x32));
|
190
|
+
rb_define_global_const("DmtxSymbol12x26", INT2FIX(DmtxSymbol12x26));
|
191
|
+
rb_define_global_const("DmtxSymbol12x36", INT2FIX(DmtxSymbol12x36));
|
192
|
+
rb_define_global_const("DmtxSymbol16x36", INT2FIX(DmtxSymbol16x36));
|
193
|
+
rb_define_global_const("DmtxSymbol16x48", INT2FIX(DmtxSymbol16x48));
|
133
194
|
}
|
metadata
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Rdmtx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Srijan Choudhary
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-11-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rmagick
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '2.16'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '2.16'
|
30
27
|
description: This is a ruby wrapper for libdmtx, which is a open source software for
|
31
28
|
reading and writing Data Matrix barcodes.
|
32
29
|
email: srijan4@gmail.com
|
@@ -38,28 +35,28 @@ files:
|
|
38
35
|
- ext/rdmtx/Rdmtx.c
|
39
36
|
- ext/rdmtx/extconf.rb
|
40
37
|
homepage: https://github.com/srijan/ruby-dmtx
|
41
|
-
licenses:
|
38
|
+
licenses:
|
39
|
+
- LGPL-2.1
|
40
|
+
metadata: {}
|
42
41
|
post_install_message:
|
43
42
|
rdoc_options: []
|
44
43
|
require_paths:
|
45
44
|
- lib
|
46
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
46
|
requirements:
|
49
|
-
- -
|
47
|
+
- - ">="
|
50
48
|
- !ruby/object:Gem::Version
|
51
49
|
version: '0'
|
52
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
51
|
requirements:
|
55
|
-
- -
|
52
|
+
- - ">="
|
56
53
|
- !ruby/object:Gem::Version
|
57
54
|
version: '0'
|
58
55
|
requirements:
|
59
56
|
- libdmtx
|
60
57
|
rubyforge_project:
|
61
|
-
rubygems_version:
|
58
|
+
rubygems_version: 2.5.1
|
62
59
|
signing_key:
|
63
|
-
specification_version:
|
60
|
+
specification_version: 4
|
64
61
|
summary: Ruby libdmtx wrapper
|
65
62
|
test_files: []
|