lib/Image/Info/ICO.pm

filter: Statementstmt 83.3% 20 / 24 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 0.0% 0 / 1 totaltotal 75.7% 25 / 33 CC 5 SCAR 15.7
CC
5
Cov
77%
process_file
5.5
BEGIN
1.0
CRAP 4.8
« lib/Image/Info.pm ↑ Summary blib/lib/Bundle/Image/Info/Everything.pm »
1 package Image::Info::ICO;
2 2 $VERSION = '0.02';
3  
4 # Copyright (C) 2009 Slaven Rezic. All rights reserved.
5 # This package is free software; you can redistribute it and/or
6 # modify it under the same terms as Perl itself.
7  
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶sub process_file {
Subroutine process_file: called CC=5 SCAR=17.1
Pod undocumented
11 3 my($info, $fh) = @_;
12  
13 3 my $buf;
14 3 ▶ if (read($fh, $buf, 6) != 6) {
Branch: 1 branch
BranchTrueFalseTotal
if (read($fh, $buf, 6) != 6) 0 3 3
15 0 $info->push_info(0, 'error' => 'Short read (expected at least 6 bytes)');
16 0 return;
17 }
18  
19 3 $info->push_info(0, 'file_media_type' => 'image/x-icon'); # XXX or is there already an official vnd format?
20 3 $info->push_info(0, 'file_ext' => 'ico');
21  
22 3 my($no_icons) = unpack('v', substr($buf, 4, 2));
23  
24 3 for my $img_no (0 .. $no_icons-1) {
25 6 ▶ if (read($fh, $buf, 16) != 16) {
Branch: 1 branch
BranchTrueFalseTotal
if (read($fh, $buf, 16) != 16) 0 6 6
26 0 $info->push_info(0, 'error' => "Short read while getting information for image at index $img_no");
27 0 return;
28 }
29 6 my($width,
30 $height,
31 $colors,
32 undef, # reserved
33 undef, # $planes
34 undef, # $bitcount
35 undef, # $size_in_bytes
36 undef, # $file_offset
37 ) = unpack('CCCCvvVV', $buf);
38 6 ▶ if ($colors == 0) { $colors = 256 }
Branch: 1 branch
BranchTrueFalseTotal
if ($colors == 0) 6 0 6
39  
40 6 $info->push_info($img_no, 'width', $width);
41 6 $info->push_info($img_no, 'height', $height);
42 6 $info->push_info($img_no, 'color_type', 'Indexed-RGB');
43 6 $info->push_info($img_no, 'colors', $colors);
44 }
45 }
46  
47 2 1;
48  
49 __END__
« lib/Image/Info.pm ↑ Summary blib/lib/Bundle/Image/Info/Everything.pm »