API2/Resource/XObject/Image/GD.pm

filter: Statementstmt 39.2% 20 / 51 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 75.0% 6 / 8 Podpod 50.0% 1 / 2 totaltotal 31.7% 27 / 85 SCAR 38.5
CC
10
Cov
28%
read_gd
56.0
new
20.0
BEGIN
1.0
CRAP 47.1
« API2/Resource/UniFont.pm ↑ Summary API2/Resource/XObject/Form/BarCode/code128.pm »
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
BranchTrueFalseTotal
if ref $class 0 0 0
19  
20 0 ▶ $self=$class->SUPER::new($pdf,$name|| 'Jx'.pdfkey());
Condition0%0/2
$name || 'Jx' . pdfkey()
l!l
00
MC/DC0%0/1
$name || 'Jx' . pdfkey()
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
21 0 ▶ $pdf->new_obj($self) unless($self->is_obj($pdf));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_obj($pdf) 0 0 0
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
BranchTrueFalseTotal
if ($gd->can('jpeg') and $c > 256 and not $opts{'-lossless'}) { } 0 0 0
elsif ($gd->can('raw')) { } 0 0 0
Condition0%0/6
$gd->can("jpeg") and $c > 256 and not $opts{"-lossless"}
!ll&&!rl&&r
000
$gd->can("jpeg") and $c > 256
!ll&&!rl&&r
000
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"}
ABCresult
0XX0
10X0
1100
1111
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
BranchTrueFalseTotal
if ($y < $h) 0 0 0
60 0 ▶ for(my $x=0;$x<$w;$x++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x < $w) 0 0 0
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;
« API2/Resource/UniFont.pm ↑ Summary API2/Resource/XObject/Form/BarCode/code128.pm »