| 1 | package PDF::API2::Resource::XObject::Image::GD; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use base 'PDF::API2::Resource::XObject::Image'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | no warnings qw[ deprecated recursion uninitialized ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '2.044'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use PDF::API2::Util; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use PDF::API2::Basic::PDF::Utils; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | my ($class,$pdf,$obj,$name,@opts) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | $self=$class->SUPER::new($pdf,$name|| 'Jx'.pdfkey()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$name || 'Jx' . pdfkey()
MC/DC0%0/1
$name || 'Jx' . pdfkey()
$name
Truth table0%0/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $pdf->new_obj($self) unless($self->is_obj($pdf)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $self->{' apipdf'}=$pdf; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | weaken $self->{' apipdf'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $self->read_gd($obj,@opts); | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub read_gd { | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $self = shift @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_gd: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $gd = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my %opts = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my ($w,$h) = $gd->getBounds(); | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $c = $gd->colorsTotal(); | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->width($w); | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $self->height($h); | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $self->bpc(8); | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $self->colorspace('DeviceRGB'); | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if($gd->can('jpeg') && ($c > 256) && !$opts{-lossless}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$gd->can("jpeg") and $c > 256 and not $opts{"-lossless"}
$gd->can("jpeg") and $c > 256
MC/DC0%0/3
$gd->can("jpeg") and $c > 256 and not $opts{"-lossless"}
$gd->can("jpeg")
$c > 256
not $opts{"-lossless"}
Truth table0%0/4
A and B and not(C)
A= $gd->can("jpeg")B= $c > 256C= not $opts{"-lossless"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $self->filters('DCTDecode'); | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->{' nofilt'}=1; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $self->{' stream'}=$gd->jpeg(75); | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } elsif($gd->can('raw')) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->filters('FlateDecode'); | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->{' stream'}=$gd->raw; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->filters('FlateDecode'); | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | for(my $y=0;$y<$h;$y++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | for(my $x=0;$x<$w;$x++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $index=$gd->getPixel($x,$y); | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my @rgb=$gd->rgb($index); | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->{' stream'}.=pack('CCC',@rgb); | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||