semacode 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ #ifndef _SEMACODE_H
2
+ #define _SEMACODE_H
3
+
4
+ #include <strings.h>
5
+ #include "iec16022ecc200.h"
6
+
7
+ typedef struct semacode_t {
8
+ int width;
9
+ int height;
10
+ int raw_encoded_length;
11
+ int symbol_capacity;
12
+ int ecc_bytes;
13
+ char *data;
14
+ } semacode_t;
15
+
16
+ #ifndef RB_STRING_VALUE
17
+ #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
18
+ #endif
19
+
20
+ #ifndef StringValuePtr
21
+ #define StringValuePtr(s) RSTRING(RB_STRING_VALUE(s))->ptr
22
+ #endif
23
+
24
+ #ifndef StringValueLen
25
+ #define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len
26
+ #endif
27
+
28
+ #endif
@@ -0,0 +1,91 @@
1
+ require 'rubygems'
2
+ require 'semacode'
3
+
4
+ def show_as_text(semacode)
5
+ show = "\n"
6
+ for row in semacode.data
7
+ show += "\t"
8
+ for column in row
9
+ if column
10
+ show += "1"
11
+ else
12
+ show += "0"
13
+ end
14
+ end
15
+ show += "\n"
16
+ end
17
+ show += "\n"
18
+ end
19
+
20
+ def show_as_html(cell_size, prefix, semacode)
21
+ show = ""
22
+ css =<<CSS
23
+ .row { clear: both; }
24
+ .black
25
+ {
26
+ background: black;
27
+ color: white;
28
+ width: #{cell_size}px;
29
+ height: #{cell_size}px;
30
+ padding: 0px;
31
+ margin: 0px;
32
+ border: 0px;
33
+ float: left;
34
+ display: block;
35
+ }
36
+
37
+ .white
38
+ {
39
+ background: white;
40
+ color: black;
41
+ width: #{cell_size}px;
42
+ height: #{cell_size}px;
43
+ padding: 0px;
44
+ margin: 0px;
45
+ border: 0px;
46
+ display: block;
47
+ float: left;
48
+ }
49
+ CSS
50
+ show += "<html><head><style>\n<!-- \n#{css} \n-->\n</style><body>"
51
+ show += "<pre>#{prefix}</pre>"
52
+ for row in semacode.data
53
+ show += "\t<div class='row'>\n"
54
+ for column in row
55
+ if column
56
+ show += "\t\t<div class='black'></div>\n"
57
+ else
58
+ show += "\t\t<div class='white'></div>\n"
59
+ end
60
+ end
61
+ show += "\t</div>\n"
62
+ end
63
+ show += "</body></html>\n"
64
+ end
65
+
66
+ def prelude
67
+ show = "\nSemacodes in Ruby\n\n"
68
+
69
+ semacode = DataMatrix::Encoder.new("http://sohne.net/projects/semafox")
70
+
71
+ show += "width #{semacode.width}\n"
72
+ show += "height #{semacode.height}\n"
73
+ show += "raw_encoded_length #{semacode.raw_encoded_length}\n"
74
+ show += "symbol_size #{semacode.symbol_size}\n"
75
+ show += "ecc_bytes #{semacode.ecc_bytes}\n"
76
+
77
+
78
+ show += "a text representation of a semacode\n\n"
79
+
80
+ text = show + show_as_text(semacode)
81
+
82
+ semacode.encode("http://sohne.net/")
83
+
84
+ html = show_as_html(8, text, semacode)
85
+ end
86
+
87
+ semacode = DataMatrix::Encoder.new "http://www.ruby-lang.org"
88
+ puts show_as_text(semacode)
89
+ # comment line above and uncomment next line
90
+ # to generate HTML instead of plain text
91
+ # puts prelude
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: semacode
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.7.0
7
+ date: 2007-03-03 00:00:00 +00:00
8
+ summary: Create semacodes (2D barcodes) using Ruby.
9
+ require_paths:
10
+ - ext
11
+ email: guido@sohne.net
12
+ homepage: http://sohne.net/projects/semafox/
13
+ rubyforge_project: semacode
14
+ description: This Ruby extension implements a DataMatrix encoder for Ruby. It is typically used to create semacodes, which are barcodes, that contain URLs. This encoder does not create image files or visual representations of the semacode. This is because it can be used for more than creating images, such as rendering semacodes to HTML, SVG, PDF or even stored in a database or file for later use.
15
+ autorequire: semacode
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Guido Sohne
31
+ files:
32
+ - ext/extconf.rb
33
+ - ext/iec16022ecc200.c
34
+ - ext/iec16022ecc200.h
35
+ - ext/reedsol.c
36
+ - ext/reedsol.h
37
+ - ext/semacode.c
38
+ - ext/semacode.h
39
+ - tests/test.rb
40
+ - README
41
+ test_files:
42
+ - tests/test.rb
43
+ rdoc_options: []
44
+
45
+ extra_rdoc_files:
46
+ - README
47
+ executables: []
48
+
49
+ extensions:
50
+ - ext/extconf.rb
51
+ requirements: []
52
+
53
+ dependencies:
54
+ - !ruby/object:Gem::Dependency
55
+ name: rake
56
+ version_requirement:
57
+ version_requirements: !ruby/object:Gem::Version::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.0
62
+ version: