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