PrettyCure/Image/PNG.pm

filter: Statementstmt 100% 11 / 11 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 84.2% 16 / 19 CC 2 SCAR 3.4
CC
2
Cov
92%
encode
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« PrettyCure/Girl/MilkyRose.pm ↑ Summary PrettyCure.pm »
1 package Acme::PrettyCure::Image::PNG;
2 1 ▶use v5.44;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # A PNG of an image, made here with Compress::Zlib rather than by Imager, for the iTerm2 protocol: the
5 # same bytes on every system (Imager's PNG support depends on the libpng it was built with), and no
6 # need for that support at all.
7  
8 1 ▶use Compress::Zlib qw(compress crc32);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # PNG of 8-bit RGB rows. $rows is an array of rows, each a string of R G B bytes.
11 1 ▶sub encode ($class, $width, $height, $rows) {
Subroutine encode: called CC=2 SCAR=7.0
Pod undocumented
12 1 ▶ die "PNG: $height rows expected\n" unless @$rows == $height;
Branch: 1 branch
BranchTrueFalseTotal
unless @$rows == $height 0 1 1
13  
14 # Each row starts with its filter type: 0, none.
15 1 my $raw = join '', map { "\0" . $_ } @$rows;
16 return
17 1 "\x89PNG\r\n\x1a\n"
18 . chunk(IHDR => pack('NNCCCCC', $width, $height, 8, 2, 0, 0, 0))
19 . chunk(IDAT => compress($raw, 9))
20 . chunk(IEND => '');
21 }
22  
23 3 ▶sub chunk ($type, $data) {
Subroutine chunk: called CC=1 SCAR=0.0
Pod undocumented
24 3 return pack('N', length $data) . $type . $data . pack('N', crc32($type . $data));
25 }
26  
27 1 1;
« PrettyCure/Girl/MilkyRose.pm ↑ Summary PrettyCure.pm »