Base.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 86.4% 32 / 37 CC 6 SCAR 14.9
CC
6
Cov
90%
convert
6.1
BEGIN
1.0
BEGIN
1.0
CRAP 4.4
↑ Summary Xpm.pm »
1 # -*- perl -*-
2  
3 # Copyright (C) 2015 Slaven Rezic. All rights reserved.
4 # This package is free software; you can redistribute it and/or
5 # modify it under the same terms as Perl itself.
6  
7 package Imager::Image::Base;
8  
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 $VERSION = '0.02';
12  
13 1 ▶use Imager ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶sub convert {
Subroutine convert: called CC=6 SCAR=18.2
Pod undocumented
16 4 my($class, $image_base) = @_;
17 4 my($w, $h) = $image_base->get('-width', '-height');
18 4 ▶ my $has_transparency = $class->can('_has_transparency') && $class->_has_transparency($image_base);
Condition66%2/3
$class->can('_has_transparency') && $class->_has_transparency($image_base)
!ll&&!rl&&r
202
MC/DC50%1/2
$class->can('_has_transparency') && $class->_has_transparency($image_base)
$class->can('_has_transparency') $class->_has_transparency($image_base)
Truth table66%2/3
A && B
A= $class->can('_has_transparency')B= $class->_has_transparency($image_base)
ABresult
0X0
100
111
19 4 my $imager = Imager->new(xsize => $w, ysize => $h, (channels => 4) x!! $has_transparency);
20 4 for my $x (0 .. $w-1) {
21 272 for my $y (0 .. $h-1) {
22 3494 my $color = $image_base->xy($x, $y);
23 3494 ▶ if ($color =~ m{^(#..)..(..)..(..)..$}) { # convert #RRRRGGGGBBBB to #RRGGBB
Branch: 2 branches
BranchTrueFalseTotal
if ($color =~ /^(#..)..(..)..(..)..$/) { } 0 3494 3494
elsif ($color =~ /^none$/i) { } 72 3422 3494
24 0 $color = "$1$2$3";
25 } elsif ($color =~ m{^none$}i) {
26 72 $color = '#00000000';
27 }
28 3494 $imager->setpixel(x => $x, y => $y, color => $color);
29 }
30 }
31 4 $imager;
32 }
33  
34 1 1;
35  
36 __END__
↑ Summary Xpm.pm »