File Coverage

blib/lib/PDF/Builder/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::Builder::Resource::ColorSpace::Indexed::ACTFile;
2              
3 1     1   936 use base 'PDF::Builder::Resource::ColorSpace::Indexed';
  1         2  
  1         104  
4              
5 1     1   7 use strict;
  1         2  
  1         19  
6 1     1   5 use warnings;
  1         1  
  1         55  
7              
8             our $VERSION = '3.024'; # VERSION
9             our $LAST_UPDATE = '3.024'; # manually update whenever code is changed
10              
11 1     1   7 use PDF::Builder::Basic::PDF::Utils;
  1         2  
  1         98  
12 1     1   8 use PDF::Builder::Util;
  1         2  
  1         114  
13 1     1   7 use Scalar::Util qw(weaken);
  1         2  
  1         280  
14              
15             =head1 NAME
16              
17             PDF::Builder::Resource::ColorSpace::Indexed::ACTFile - Adobe Color Table support
18              
19             =head1 METHODS
20              
21             =over
22              
23             =item $cs = PDF::Builder::Resource::ColorSpace::Indexed::ACTFile->new($pdf, $actfile)
24              
25             Returns a new colorspace object created from an adobe color table file (ACT/8BCT).
26             See
27             Adobe Photoshop(R) 6.0 --
28             File Formats Specification Version 6.0 Release 2,
29             November 2000
30             for details.
31              
32             =cut
33              
34             sub new {
35 0     0 1   my ($class, $pdf, $file) = @_;
36              
37 0 0         die "could not find act-file '$file'." unless -f $file;
38 0 0         $class = ref($class) if ref($class);
39 0           my $self = $class->SUPER::new($pdf, pdfkey());
40 0 0         $pdf->new_obj($self) unless $self->is_obj($pdf);
41 0           $self->{' apipdf'} = $pdf;
42 0           weaken $self->{' apipdf'};
43 0           my $csd = PDFDict();
44 0           $pdf->new_obj($csd);
45 0           $csd->{'Filter'} = PDFArray(PDFName('FlateDecode'));
46             # default values in case file is missing or bad??
47             #$csd->{'WhitePoint'} = PDFArray(map {PDFNum($_)} (0.95049, 1, 1.08897));
48             #$csd->{'BlackPoint'} = PDFArray(map {PDFNum($_)} (0, 0, 0));
49             #$csd->{'Gamma'} = PDFArray(map {PDFNum($_)} (2.22218, 2.22218, 2.22218));
50              
51 0           my $fh;
52 0 0         open($fh, "<", $file) or die "$!: $file";
53 0           binmode($fh, ':raw');
54 0           read($fh, $csd->{' stream'}, 768);
55 0           close($fh);
56              
57 0           $csd->{' stream'} .= "\x00" x 768;
58 0           $csd->{' stream'} = substr($csd->{' stream'}, 0, 768);
59              
60 0           $self->add_elements(PDFName('DeviceRGB'), PDFNum(255), $csd);
61 0           $self->{' csd'} = $csd;
62              
63 0           return $self;
64             }
65              
66             =back
67              
68             =cut
69              
70             1;