| 1 | package PDF::API2::Resource::XObject::Image; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use base 'PDF::API2::Resource::XObject'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 7 | our $VERSION = '2.044'; # VERSION | |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use PDF::API2::Basic::PDF::Utils; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 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 | ▶ | my ($class, $pdf, $name) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 28 | 18 | my $self = $class->SUPER::new($pdf, $name); | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 18 | $self->subtype('Image'); | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 18 | 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 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||
|
Subroutine
width: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 43 | 23 | ▶ | $self->{'Width'} = PDFNum(shift()) if scalar @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | 23 | 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 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||
|
Subroutine
height: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 55 | 14 | ▶ | $self->{'Height'} = PDFNum(shift()) if scalar @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 56 | 14 | 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 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||
|
Subroutine
smask: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 67 | 0 | $self->{'SMask'} = shift(); | |||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 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 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||
|
Subroutine
mask: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if (ref($_[0])) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 84 | 0 | $self->{'Mask'} = shift(); | |||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | else { | ||||||||||||||||||||||||||||||||
| 87 | 0 | $self->{'Mask'} = PDFArray(map { PDFNum($_) } @_); | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | # Deprecated (rolled into mask) | ||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub imask { return mask(@_); } | ||||||||||||||||||||||||||||||
|
Subroutine
imask: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 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 | ▶ | my ($self, @values) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
colorspace: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 112 | 14 | ▶ | if (scalar @values == 1 and ref($values[0])) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
scalar @values == 1 and ref $values[0]
MC/DC50%1/2
scalar @values == 1 and ref $values[0]
scalar @values == 1
ref $values[0]
Truth table66%2/3
A and B
A= scalar @values == 1B= ref $values[0]
| |||||||||||||||||||||||||||||||||
| 113 | 4 | $self->{'ColorSpace'} = $values[0]; | |||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | elsif (scalar @values == 1) { | ||||||||||||||||||||||||||||||||
| 116 | 10 | $self->{'ColorSpace'} = PDFName($values[0]); | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | else { | ||||||||||||||||||||||||||||||||
| 119 | 0 | $self->{'ColorSpace'} = PDFArray(@values); | |||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | 14 | 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 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||
|
Subroutine
bits_per_component: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 133 | 14 | $self->{'BitsPerComponent'} = PDFNum(shift()); | |||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 14 | return $self; | |||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | # Deprecated (renamed) | ||||||||||||||||||||||||||||||||
| 139 | 12 | ▶ | sub bpc { return bits_per_component(@_); } | ||||||||||||||||||||||||||||||
|
Subroutine
bpc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | =back | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | =cut | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 7 | 1; | |||||||||||||||||||||||||||||||