line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Barcode::DataMatrix; |
2
|
2
|
|
|
2
|
|
43176
|
use Moo; |
|
2
|
|
|
|
|
34121
|
|
|
2
|
|
|
|
|
10
|
|
3
|
2
|
|
|
2
|
|
5361
|
use Type::Tiny; |
|
2
|
|
|
|
|
43042
|
|
|
2
|
|
|
|
|
133
|
|
4
|
2
|
|
|
2
|
|
1874
|
use Types::Standard qw(:all); |
|
2
|
|
|
|
|
100019
|
|
|
2
|
|
|
|
|
20
|
|
5
|
2
|
|
|
2
|
|
84420
|
use Type::Utils qw(enum); |
|
2
|
|
|
|
|
9605
|
|
|
2
|
|
|
|
|
18
|
|
6
|
2
|
|
|
2
|
|
2387
|
use Barcode::DataMatrix::Engine (); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
569
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
## no critic (RequireUseWarnings, RequireUseStrict) |
9
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'encoding_mode' => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
isa => enum([qw[ ASCII C40 TEXT BASE256 NONE AUTO ]]), |
14
|
|
|
|
|
|
|
isa => enum(BCDM_EncodingMode => [qw[ ASCII C40 TEXT BASE256 NONE AUTO ]]), |
15
|
|
|
|
|
|
|
required => 1, |
16
|
|
|
|
|
|
|
default => 'AUTO', |
17
|
|
|
|
|
|
|
documentation => 'The encoding mode for the data matrix. Can be one of: ASCII C40 TEXT BASE256 NONE AUTO', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
has 'process_tilde' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => Bool, |
22
|
|
|
|
|
|
|
required => 0, |
23
|
|
|
|
|
|
|
default => 0, |
24
|
|
|
|
|
|
|
documentation => 'Set to true to indicate the tilde character "~" is being used to recognize special characters.', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Barcode::DataMatrix - Generate data for Data Matrix barcodes |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use Barcode::DataMatrix; |
34
|
|
|
|
|
|
|
my $data = Barcode::DataMatrix->new->barcode('MONKEY'); |
35
|
|
|
|
|
|
|
for my $row (@$data) { |
36
|
|
|
|
|
|
|
print for map { $_ ? "#" : ' ' } @$row; |
37
|
|
|
|
|
|
|
print "\n"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This class is used to generate data for Data Matrix barcodes. It is primarily |
45
|
|
|
|
|
|
|
useful as a data source for barcode modules that do rendering, |
46
|
|
|
|
|
|
|
such as L. You can easily make a version that |
47
|
|
|
|
|
|
|
renders an image, PDF, or anything else. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 new (%attributes) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Instantiate a new Barcode::DataMatrix object. The C<%attributes> hash |
54
|
|
|
|
|
|
|
can take any of the other L listed below. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 barcode ($text) |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Generate barcode data representing the C<$text> string. This returns |
61
|
|
|
|
|
|
|
an array ref of rows in the data matrix, each containing array refs of |
62
|
|
|
|
|
|
|
cells within that row. The cells are true and false values |
63
|
|
|
|
|
|
|
that represent filled or empty squares. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This can throw an exception if it's unable to generate the barcode data. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub barcode { |
70
|
12
|
|
|
12
|
1
|
193762
|
my ($self, $text) = @_; |
71
|
|
|
|
|
|
|
|
72
|
12
|
|
|
|
|
93
|
my $engine = Barcode::DataMatrix::Engine->new( |
73
|
|
|
|
|
|
|
$text, |
74
|
|
|
|
|
|
|
$self->encoding_mode, |
75
|
|
|
|
|
|
|
undef, # size |
76
|
|
|
|
|
|
|
$self->process_tilde, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
12
|
|
|
|
|
28
|
my $rows = $engine->{rows}; |
80
|
12
|
|
|
|
|
20
|
my $cols = $engine->{cols}; |
81
|
12
|
|
|
|
|
24
|
my $bitmap = $engine->{bitmap}; |
82
|
12
|
|
|
|
|
21
|
my $rv = []; |
83
|
12
|
|
|
|
|
33
|
for my $r (0 .. $rows - 1) { |
84
|
390
|
|
|
|
|
541
|
my $row = []; |
85
|
390
|
|
|
|
|
642
|
for my $c (0 .. $cols - 1) { |
86
|
17212
|
100
|
|
|
|
33622
|
push @$row, ($bitmap->[$c]->[$r] ? 1 : 0); |
87
|
|
|
|
|
|
|
} |
88
|
390
|
|
|
|
|
652
|
push @$rv, $row; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
12
|
|
|
|
|
474
|
return $rv; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 encoding_mode |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The encoding mode for the data matrix. Can be one of: |
99
|
|
|
|
|
|
|
C (default), C, C, C, C, or C. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 process_tilde |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Set to true to indicate the tilde character "~" is being used to recognize |
104
|
|
|
|
|
|
|
special characters. See this page for more information: |
105
|
|
|
|
|
|
|
L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHORS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Mons Anderson C<< >> (GD::Barcode::DataMatrix at L, from which this distribution originates) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Mark A. Stratman, C<< >> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Paul Cochrane, L |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SOURCE REPOSITORY |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SEE ALSO |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over 4 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item L |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item L |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Copyright 2015 the AUTHORs listed above. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
138
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
139
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; # End of Barcode::DataMatrix |