line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Builder::Resource::XObject::Image; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1345
|
use base 'PDF::Builder::Resource::XObject'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
558
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
35
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
111
|
|
6
|
6
|
|
|
6
|
|
24
|
use warnings; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
278
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '3.024'; # VERSION |
9
|
|
|
|
|
|
|
our $LAST_UPDATE = '3.017'; # manually update whenever code is changed |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
31
|
use PDF::Builder::Basic::PDF::Utils; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
2902
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PDF::Builder::Resource::XObject::Image - Base class for external raster image objects |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=over |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=item $image = PDF::Builder::Resource::XObject::Image->new($pdf, $name) |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Returns an image resource object. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
17
|
|
|
17
|
1
|
40
|
my ($class, $pdf, $name) = @_; |
29
|
|
|
|
|
|
|
|
30
|
17
|
|
|
|
|
79
|
my $self = $class->SUPER::new($pdf, $name); |
31
|
|
|
|
|
|
|
|
32
|
17
|
|
|
|
|
63
|
$self->subtype('Image'); |
33
|
|
|
|
|
|
|
|
34
|
17
|
|
|
|
|
35
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item $width = $image->width($width) |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Get or set the width value for the image object. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub width { |
44
|
22
|
|
|
22
|
1
|
5484
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
22
|
100
|
|
|
|
78
|
$self->{'Width'} = PDFNum(shift()) if scalar @_; |
47
|
22
|
|
|
|
|
71
|
return $self->{'Width'}->val(); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item $height = $image->height($height) |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Get or set the height value for the image object. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub height { |
57
|
13
|
|
|
13
|
1
|
20
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
13
|
50
|
|
|
|
47
|
$self->{'Height'} = PDFNum(shift()) if scalar @_; |
60
|
13
|
|
|
|
|
33
|
return $self->{'Height'}->val(); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item $image->smask($xobject) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Set the soft-mask image object. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub smask { |
70
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
71
|
0
|
|
|
|
|
0
|
$self->{'SMask'} = shift; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
return $self; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item $image->mask(@color_range) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item $image->mask($xobject) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Set the mask to an image mask XObject or an array containing a range |
81
|
|
|
|
|
|
|
of colors to be applied as a color key mask. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub mask { |
86
|
0
|
|
|
0
|
1
|
0
|
my $self = shift(); |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
0
|
if (ref($_[0])) { |
89
|
0
|
|
|
|
|
0
|
$self->{'Mask'} = shift(); |
90
|
|
|
|
|
|
|
} else { |
91
|
0
|
|
|
|
|
0
|
$self->{'Mask'} = PDFArray(map { PDFNum($_) } @_); |
|
0
|
|
|
|
|
0
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
0
|
return $self; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# imask() functionality rolled into mask() |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item $image->colorspace($name) |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item $image->colorspace($array) |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Set the color space used by the image. Depending on the color space, |
104
|
|
|
|
|
|
|
this will either be just the name of the color space, or it will be an |
105
|
|
|
|
|
|
|
array containing the color space and any required parameters. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
If passing an array, parameters must already be encoded as PDF |
108
|
|
|
|
|
|
|
objects. The array itself may also be a PDF object. If not, one will |
109
|
|
|
|
|
|
|
be created. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub colorspace { |
114
|
13
|
|
|
13
|
1
|
34
|
my ($self, @values) = @_; |
115
|
|
|
|
|
|
|
|
116
|
13
|
100
|
66
|
|
|
65
|
if (scalar @values == 1 and ref($values[0])) { |
|
|
50
|
|
|
|
|
|
117
|
4
|
|
|
|
|
9
|
$self->{'ColorSpace'} = $values[0]; |
118
|
|
|
|
|
|
|
} elsif (scalar @values == 1) { |
119
|
9
|
|
|
|
|
25
|
$self->{'ColorSpace'} = PDFName($values[0]); |
120
|
|
|
|
|
|
|
} else { |
121
|
0
|
|
|
|
|
0
|
$self->{'ColorSpace'} = PDFArray(@values); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
13
|
|
|
|
|
27
|
return $self; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item $image->bits_per_component($integer) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Set the number of bits used to represent each color component. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub bits_per_component { |
134
|
13
|
|
|
13
|
1
|
24
|
my $self = shift; |
135
|
|
|
|
|
|
|
|
136
|
13
|
|
|
|
|
30
|
$self->{'BitsPerComponent'} = PDFNum(shift()); |
137
|
|
|
|
|
|
|
|
138
|
13
|
|
|
|
|
25
|
return $self; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# bpc() renamed to bits_per_component() |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |