line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Builder::Resource::XObject::Image::GD; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1575
|
use base 'PDF::Builder::Resource::XObject::Image'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
132
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
7
|
|
|
|
|
|
|
#no warnings qw[ deprecated recursion uninitialized ]; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '3.023'; # VERSION |
10
|
|
|
|
|
|
|
our $LAST_UPDATE = '3.021'; # manually update whenever code is changed |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use PDF::Builder::Util; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
159
|
|
13
|
1
|
|
|
1
|
|
9
|
use PDF::Builder::Basic::PDF::Utils; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
77
|
|
14
|
1
|
|
|
1
|
|
7
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
419
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
PDF::Builder::Resource::XObject::Image::GD - support routines for Graphics Development image library. Inherits from L |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
0
|
|
|
0
|
1
|
|
my ($class, $pdf, $obj, $name, @opts) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $self; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
$class = ref $class if ref $class; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
0
|
|
|
|
$self = $class->SUPER::new($pdf, $name || 'Jx'.pdfkey()); |
30
|
0
|
0
|
|
|
|
|
$pdf->new_obj($self) unless $self->is_obj($pdf); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$self->{' apipdf'} = $pdf; |
33
|
0
|
|
|
|
|
|
weaken $self->{' apipdf'}; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$self->read_gd($obj, @opts); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub read_gd { |
41
|
0
|
|
|
0
|
0
|
|
my ($self, $gd, %opts) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my ($w,$h) = $gd->getBounds(); |
44
|
0
|
|
|
|
|
|
my $c = $gd->colorsTotal(); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$self->width($w); |
47
|
0
|
|
|
|
|
|
$self->height($h); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$self->bits_per_component(8); |
50
|
0
|
|
|
|
|
|
$self->colorspace('DeviceRGB'); |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
0
|
|
|
|
if ($gd->can('jpeg') && ($c > 256) && !$opts{'-lossless'}) { |
|
|
0
|
0
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->filters('DCTDecode'); |
55
|
0
|
|
|
|
|
|
$self->{' nofilt'} = 1; |
56
|
0
|
|
|
|
|
|
$self->{' stream'} = $gd->jpeg(75); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} elsif ($gd->can('raw')) { |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->filters('FlateDecode'); |
61
|
0
|
|
|
|
|
|
$self->{' stream'} = $gd->raw(); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} else { |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->filters('FlateDecode'); |
66
|
0
|
|
|
|
|
|
for(my $y=0; $y<$h; $y++) { |
67
|
0
|
|
|
|
|
|
for(my $x=0; $x<$w; $x++) { |
68
|
0
|
|
|
|
|
|
my $index = $gd->getPixel($x,$y); |
69
|
0
|
|
|
|
|
|
my @rgb = $gd->rgb($index); |
70
|
0
|
|
|
|
|
|
$self->{' stream'} .= pack('CCC', @rgb); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |