File Coverage

blib/lib/Imager/Image/Xpm.pm
Criterion Covered Total %
statement 23 24 95.8
branch 7 8 87.5
condition 1 2 50.0
subroutine 6 6 100.0
pod 0 1 0.0
total 37 41 90.2


line stmt bran cond sub pod time code
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::Xpm;
8              
9 1     1   501 use strict;
  1         3  
  1         51  
10 1     1   7 use vars qw($VERSION);
  1         1  
  1         56  
11             $VERSION = '0.01';
12              
13 1     1   4 use base 'Imager::Image::Base';
  1         1  
  1         104  
14              
15 1     1   533 use Image::Xpm;
  1         4643  
  1         187  
16              
17             sub new {
18 4     4 0 1771 my($class, %opts) = @_;
19 4         11 my $file = delete $opts{file};
20 4 100       23 die 'file option is mandatory' if !defined $file;
21 3 100       16 die 'Unhandled options: ' . join(' ', %opts) if %opts;
22 2         21 my $xpm = Image::Xpm->new(-file => $file);
23 2         1101 Imager::Image::Xpm->convert($xpm);
24             }
25              
26             sub _has_transparency {
27 2     2   4 my(undef, $image_base) = @_;
28 2         6 my $palette = $image_base->get('-palette');
29 2 50       15 if ($palette) {
30 2         5 for my $color_spec (values %$palette) {
31 4 100 50     22 return 1 if ($color_spec->{'c'}||'') =~m{^none$}i;
32             }
33             }
34 0           0;
35             }
36              
37             1;
38              
39             __END__