line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GD::Barcode::Code39; |
2
|
1
|
|
|
1
|
|
224653
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
404
|
use GD::Barcode; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
47
|
|
6
|
1
|
|
|
1
|
|
6
|
use parent qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
48
|
use vars qw($VERSION @ISA $errStr); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
628
|
|
8
|
|
|
|
|
|
|
@ISA = qw(GD::Barcode Exporter); |
9
|
|
|
|
|
|
|
our $VERSION = '1.99_03'; |
10
|
|
|
|
|
|
|
my $code39Bar = { |
11
|
|
|
|
|
|
|
'0' => '000110100', |
12
|
|
|
|
|
|
|
'1' => '100100001', |
13
|
|
|
|
|
|
|
'2' => '001100001', |
14
|
|
|
|
|
|
|
'3' => '101100000', |
15
|
|
|
|
|
|
|
'4' => '000110001', |
16
|
|
|
|
|
|
|
'5' => '100110000', |
17
|
|
|
|
|
|
|
'6' => '001110000', |
18
|
|
|
|
|
|
|
'7' => '000100101', |
19
|
|
|
|
|
|
|
'8' => '100100100', |
20
|
|
|
|
|
|
|
'9' => '001100100', |
21
|
|
|
|
|
|
|
'A' => '100001001', |
22
|
|
|
|
|
|
|
'B' => '001001001', |
23
|
|
|
|
|
|
|
'C' => '101001000', |
24
|
|
|
|
|
|
|
'D' => '000011001', |
25
|
|
|
|
|
|
|
'E' => '100011000', |
26
|
|
|
|
|
|
|
'F' => '001011000', |
27
|
|
|
|
|
|
|
'G' => '000001101', |
28
|
|
|
|
|
|
|
'H' => '100001100', |
29
|
|
|
|
|
|
|
'I' => '001001100', |
30
|
|
|
|
|
|
|
'J' => '000011100', |
31
|
|
|
|
|
|
|
'K' => '100000011', |
32
|
|
|
|
|
|
|
'L' => '001000011', |
33
|
|
|
|
|
|
|
'M' => '101000010', |
34
|
|
|
|
|
|
|
'N' => '000010011', |
35
|
|
|
|
|
|
|
'O' => '100010010', |
36
|
|
|
|
|
|
|
'P' => '001010010', |
37
|
|
|
|
|
|
|
'Q' => '000000111', |
38
|
|
|
|
|
|
|
'R' => '100000110', |
39
|
|
|
|
|
|
|
'S' => '001000110', |
40
|
|
|
|
|
|
|
'T' => '000010110', |
41
|
|
|
|
|
|
|
'U' => '110000001', |
42
|
|
|
|
|
|
|
'V' => '011000001', |
43
|
|
|
|
|
|
|
'W' => '111000000', |
44
|
|
|
|
|
|
|
'X' => '010010001', |
45
|
|
|
|
|
|
|
'Y' => '110010000', |
46
|
|
|
|
|
|
|
'Z' => '011010000', |
47
|
|
|
|
|
|
|
'-' => '010000101', |
48
|
|
|
|
|
|
|
'*' => '010010100', |
49
|
|
|
|
|
|
|
'+' => '010001010', |
50
|
|
|
|
|
|
|
'$' => '010101000', |
51
|
|
|
|
|
|
|
'%' => '000101010', |
52
|
|
|
|
|
|
|
'/' => '010100010', |
53
|
|
|
|
|
|
|
'.' => '110000100', |
54
|
|
|
|
|
|
|
' ' => '011000100' |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub new { |
58
|
1
|
|
|
1
|
1
|
88
|
my ( $sClass, $sTxt ) = @_; |
59
|
1
|
|
|
|
|
10
|
$errStr = ''; |
60
|
1
|
|
|
|
|
3
|
my $oThis = {}; |
61
|
1
|
|
|
|
|
2
|
bless $oThis, $sClass; |
62
|
1
|
50
|
|
|
|
4
|
return if ( $errStr = $oThis->init($sTxt) ); |
63
|
1
|
|
|
|
|
4
|
return $oThis; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub init { |
67
|
1
|
|
|
1
|
0
|
3
|
my ( $oThis, $sTxt ) = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#Check |
70
|
1
|
50
|
|
|
|
5
|
return 'Invalid Characters' if ( $sTxt =~ /[^0-9A-Z\-*+\$%\/. ]/ ); |
71
|
1
|
|
|
|
|
8
|
$oThis->{text} = $sTxt; |
72
|
1
|
|
|
|
|
4
|
return ''; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub barcode { |
76
|
1
|
|
|
1
|
1
|
2
|
my ($oThis) = @_; |
77
|
1
|
|
|
|
|
2
|
my ($sTxt); |
78
|
1
|
|
|
|
|
2
|
my ( $sWk, $sRes ); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
2
|
$sTxt = $oThis->{text}; |
81
|
1
|
|
|
|
|
2
|
$sRes = ''; |
82
|
1
|
|
|
|
|
6
|
foreach my $sWk ( split( //, $sTxt ) ) { |
83
|
7
|
|
|
|
|
22
|
$sRes .= GD::Barcode::dumpCode( $code39Bar->{$sWk} . '0' ); |
84
|
|
|
|
|
|
|
} |
85
|
1
|
|
|
|
|
8
|
return $sRes; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub plot { |
89
|
0
|
|
|
0
|
1
|
|
my ( $oThis, %hParam ) = @_; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#Barcode Pattern |
92
|
0
|
|
|
|
|
|
my $sTxtWk = $oThis->{text}; |
93
|
0
|
|
|
|
|
|
my $sPtn = $oThis->barcode(); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
#Create Image |
96
|
0
|
0
|
|
|
|
|
my $iHeight = ( $hParam{Height} ) ? $hParam{Height} : 50; |
97
|
0
|
|
|
|
|
|
my ( $oGd, $cBlack ); |
98
|
0
|
0
|
|
|
|
|
if ( $hParam{NoText} ) { |
99
|
0
|
|
|
|
|
|
( $oGd, $cBlack ) = |
100
|
|
|
|
|
|
|
GD::Barcode::plot( $sPtn, length($sPtn), $iHeight, 0, 0 ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
else { |
103
|
0
|
|
|
|
|
|
require GD; |
104
|
0
|
|
|
|
|
|
my ( $fW, $fH ) = ( GD::Font->Small->width, GD::Font->Small->height ); |
105
|
0
|
|
|
|
|
|
my $iWidth = length($sPtn); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#Bar Image |
108
|
0
|
|
|
|
|
|
( $oGd, $cBlack ) = |
109
|
|
|
|
|
|
|
GD::Barcode::plot( $sPtn, $iWidth, $iHeight, $fH, 0 ); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
#String |
112
|
0
|
|
|
|
|
|
$oGd->string( |
113
|
|
|
|
|
|
|
GD::Font->Small, |
114
|
|
|
|
|
|
|
( length($sPtn) - $fW * ( length($sTxtWk) ) ) / 2, |
115
|
|
|
|
|
|
|
$iHeight - $fH, |
116
|
|
|
|
|
|
|
$sTxtWk, $cBlack |
117
|
|
|
|
|
|
|
); |
118
|
|
|
|
|
|
|
} |
119
|
0
|
|
|
|
|
|
return $oGd; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
__END__ |