File Coverage

blib/lib/PDF/API2/Resource/ColorSpace/Indexed/ACTFile.pm
Criterion Covered Total %
statement 18 38 47.3
branch 0 8 0.0
condition n/a
subroutine 6 7 85.7
pod 1 1 100.0
total 25 54 46.3


line stmt bran cond sub pod time code
1             package PDF::API2::Resource::ColorSpace::Indexed::ACTFile;
2              
3 1     1   990 use base 'PDF::API2::Resource::ColorSpace::Indexed';
  1         3  
  1         105  
4              
5 1     1   6 use strict;
  1         2  
  1         21  
6 1     1   6 use warnings;
  1         2  
  1         40  
7              
8             our $VERSION = '2.045'; # VERSION
9              
10 1     1   7 use PDF::API2::Basic::PDF::Utils;
  1         2  
  1         89  
11 1     1   7 use PDF::API2::Util;
  1         2  
  1         148  
12 1     1   7 use Scalar::Util qw(weaken);
  1         3  
  1         320  
13              
14             =head1 NAME
15              
16             PDF::API2::Resource::ColorSpace::Indexed::ACTFile - Adobe Color Table support
17              
18             =head1 METHODS
19              
20             =over
21              
22             =item $cs = PDF::API2::Resource::ColorSpace::Indexed::ACTFile->new $pdf, $actfile
23              
24             Returns a new colorspace object created from an adobe color table file (ACT/8BCT).
25             See
26             Adobe Photoshop(R) 6.0 --
27             File Formats Specification Version 6.0 Release 2,
28             November 2000
29             for details.
30              
31             =cut
32              
33             sub new {
34 0     0 1   my ($class, $pdf, $file) = @_;
35 0 0         die "could not find act-file '$file'." unless -f $file;
36 0 0         $class = ref($class) if ref($class);
37 0           my $self = $class->SUPER::new($pdf, pdfkey());
38 0 0         $pdf->new_obj($self) unless $self->is_obj($pdf);
39 0           $self->{' apipdf'} = $pdf;
40 0           weaken $self->{' apipdf'};
41 0           my $csd = PDFDict();
42 0           $pdf->new_obj($csd);
43 0           $csd->{'Filter'} = PDFArray(PDFName('FlateDecode'));
44              
45 0           my $fh;
46 0 0         open($fh, "<", $file) or die "$!: $file";
47 0           binmode($fh, ':raw');
48 0           read($fh, $csd->{' stream'}, 768);
49 0           close($fh);
50              
51 0           $csd->{' stream'} .= "\x00" x 768;
52 0           $csd->{' stream'} = substr($csd->{' stream'}, 0, 768);
53              
54 0           $self->add_elements(PDFName('DeviceRGB'), PDFNum(255), $csd);
55 0           $self->{' csd'} = $csd;
56              
57 0           return $self;
58             }
59              
60             =back
61              
62             =cut
63              
64             1;