line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GD::Barcode; |
2
|
13
|
|
|
13
|
|
2112175
|
use parent qw(Exporter); |
|
13
|
|
|
|
|
4139
|
|
|
13
|
|
|
|
|
121
|
|
3
|
13
|
|
|
13
|
|
722
|
use strict; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
229
|
|
4
|
13
|
|
|
13
|
|
63
|
use warnings; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
347
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
68
|
use vars qw( @ISA $errStr); |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
543
|
|
7
|
13
|
|
|
13
|
|
68
|
use parent qw(Exporter); |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
47
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.00'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
11
|
|
|
11
|
1
|
780
|
my ( $sClass, $sType, $sTxt, $rhPrm ) = @_; |
12
|
11
|
|
|
|
|
28
|
my $oThis = {}; |
13
|
11
|
|
|
|
|
39
|
my $module = "GD::Barcode::$sType"; |
14
|
11
|
|
|
|
|
640
|
eval "require $module;"; |
15
|
11
|
100
|
|
|
|
75
|
if ($@) { |
16
|
1
|
|
|
|
|
5
|
$errStr = "Can't load $sType : $@"; |
17
|
1
|
|
|
|
|
8
|
return; |
18
|
|
|
|
|
|
|
} |
19
|
10
|
|
|
|
|
46
|
bless $oThis, $module; |
20
|
10
|
50
|
|
|
|
45
|
return if ( $errStr = $oThis->init( $sTxt, $rhPrm ) ); |
21
|
10
|
|
|
|
|
46
|
return $oThis; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub barPtn { |
25
|
62
|
|
|
62
|
0
|
120
|
my ( $bar, $table ) = @_; |
26
|
62
|
|
|
|
|
81
|
my $sRes; |
27
|
|
|
|
|
|
|
|
28
|
62
|
|
|
|
|
74
|
$sRes = ''; |
29
|
62
|
|
|
|
|
117
|
foreach my $sWk ( split( //, $bar ) ) { |
30
|
62
|
|
|
|
|
124
|
$sRes .= $table->{$sWk}; |
31
|
|
|
|
|
|
|
} |
32
|
62
|
|
|
|
|
183
|
return $sRes; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub dumpCode { |
36
|
16
|
|
|
16
|
0
|
28
|
my ($sCode) = @_; |
37
|
16
|
|
|
|
|
20
|
my ( $sRes, $sClr ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#Init |
40
|
16
|
|
|
|
|
22
|
$sRes = ''; |
41
|
16
|
|
|
|
|
21
|
$sClr = '1'; # 1: Black, 0:White |
42
|
|
|
|
|
|
|
|
43
|
16
|
|
|
|
|
44
|
foreach my $sWk ( split( //, $sCode ) ) { |
44
|
142
|
100
|
|
|
|
244
|
$sRes .= ( $sWk eq '1' ) ? $sClr x 3 : $sClr; #3 times or Normal |
45
|
142
|
100
|
|
|
|
223
|
$sClr = ( $sClr eq '0' ) ? '1' : '0'; |
46
|
|
|
|
|
|
|
} |
47
|
16
|
|
|
|
|
50
|
return $sRes; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub plot { |
51
|
0
|
|
|
0
|
1
|
|
my ( $sBarcode, $iWidth, $iHeight, $fH, $iStart ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#Create Image |
54
|
0
|
|
|
|
|
|
my ( $gdNew, $cWhite, $cBlack ); |
55
|
0
|
|
|
|
|
|
eval { |
56
|
0
|
|
|
|
|
|
$gdNew = GD::Image->new( $iWidth, $iHeight ); |
57
|
0
|
|
|
|
|
|
$cWhite = $gdNew->colorAllocate( 255, 255, 255 ); |
58
|
0
|
|
|
|
|
|
$cBlack = $gdNew->colorAllocate( 0, 0, 0 ); |
59
|
0
|
|
|
|
|
|
$gdNew->filledRectangle( 0, 0, $iWidth, $iHeight, $cWhite ); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $iPos = $iStart; |
62
|
0
|
|
|
|
|
|
foreach my $cWk ( split( //, $sBarcode ) ) { |
63
|
0
|
0
|
|
|
|
|
if ( $cWk eq '0' ) { |
|
|
0
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$gdNew->line( $iPos, 0, $iPos, $iHeight - $fH, $cWhite ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
elsif ( $cWk eq 'G' ) { |
67
|
0
|
|
|
|
|
|
$gdNew->line( $iPos, 0, $iPos, $iHeight - 2 * ( $fH / 3 ), |
68
|
|
|
|
|
|
|
$cBlack ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { #$cWk eq "1" etc. |
71
|
0
|
|
|
|
|
|
$gdNew->line( $iPos, 0, $iPos, $iHeight - $fH, $cBlack ); |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
|
$iPos++; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
}; |
76
|
0
|
|
|
|
|
|
return ( $gdNew, $cBlack ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
__END__ |