line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=======================================================================
|
2
|
|
|
|
|
|
|
# ____ ____ _____ _ ____ ___ ____
|
3
|
|
|
|
|
|
|
# | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \
|
4
|
|
|
|
|
|
|
# | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) |
|
5
|
|
|
|
|
|
|
# | __/| |_| | _| _ _ / ___ \| __/| | / __/
|
6
|
|
|
|
|
|
|
# |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____|
|
7
|
|
|
|
|
|
|
#
|
8
|
|
|
|
|
|
|
# A Perl Module Chain to faciliate the Creation and Modification
|
9
|
|
|
|
|
|
|
# of High-Quality "Portable Document Format (PDF)" Files.
|
10
|
|
|
|
|
|
|
#
|
11
|
|
|
|
|
|
|
# Copyright 1999-2005 Alfred Reibenschuh .
|
12
|
|
|
|
|
|
|
#
|
13
|
|
|
|
|
|
|
#=======================================================================
|
14
|
|
|
|
|
|
|
#
|
15
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or
|
16
|
|
|
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
17
|
|
|
|
|
|
|
# License as published by the Free Software Foundation; either
|
18
|
|
|
|
|
|
|
# version 2 of the License, or (at your option) any later version.
|
19
|
|
|
|
|
|
|
#
|
20
|
|
|
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
21
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
23
|
|
|
|
|
|
|
# Lesser General Public License for more details.
|
24
|
|
|
|
|
|
|
#
|
25
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
26
|
|
|
|
|
|
|
# License along with this library; if not, write to the
|
27
|
|
|
|
|
|
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
28
|
|
|
|
|
|
|
# Boston, MA 02111-1307, USA.
|
29
|
|
|
|
|
|
|
#
|
30
|
|
|
|
|
|
|
# $Id: WebColor.pm,v 2.0 2005/11/16 02:18:14 areibens Exp $
|
31
|
|
|
|
|
|
|
#
|
32
|
|
|
|
|
|
|
#=======================================================================
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package PDF::API3::Compat::API2::Resource::ColorSpace::Indexed::WebColor;
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
BEGIN {
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
7
|
use strict;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
52
|
|
39
|
1
|
|
|
1
|
|
7
|
use vars qw(@ISA $VERSION);
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
62
|
|
40
|
1
|
|
|
1
|
|
6
|
use PDF::API3::Compat::API2::Resource::ColorSpace::Indexed;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
41
|
1
|
|
|
1
|
|
6
|
use PDF::API3::Compat::API2::Basic::PDF::Utils;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
174
|
|
42
|
1
|
|
|
1
|
|
7
|
use PDF::API3::Compat::API2::Util;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
226
|
|
43
|
1
|
|
|
1
|
|
7
|
use POSIX;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
3872
|
@ISA = qw( PDF::API3::Compat::API2::Resource::ColorSpace::Indexed );
|
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
58
|
( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.0 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2005/11/16 02:18:14 $
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
}
|
50
|
1
|
|
|
1
|
|
12
|
no warnings qw[ deprecated recursion uninitialized ];
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
672
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item $cs = PDF::API3::Compat::API2::Resource::ColorSpace::Indexed::WebColor->new $pdf
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Returns a new colorspace object created from the web color palette.
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new {
|
59
|
0
|
|
|
0
|
1
|
|
my ($class,$pdf)=@_;
|
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
$class = ref $class if ref $class;
|
62
|
0
|
|
|
|
|
|
$self=$class->SUPER::new($pdf,pdfkey());
|
63
|
0
|
0
|
|
|
|
|
$pdf->new_obj($self) unless($self->is_obj($pdf));
|
64
|
0
|
|
|
|
|
|
$self->{' apipdf'}=$pdf;
|
65
|
0
|
|
|
|
|
|
my $csd=PDFDict();
|
66
|
0
|
|
|
|
|
|
$pdf->new_obj($csd);
|
67
|
0
|
|
|
|
|
|
$csd->{Filter}=PDFArray(PDFName('ASCIIHexDecode'));
|
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
$csd->{WhitePoint}=PDFArray(map {PDFNum($_)} (0.95049, 1, 1.08897));
|
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$csd->{BlackPoint}=PDFArray(map {PDFNum($_)} (0, 0, 0));
|
|
0
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$csd->{Gamma}=PDFArray(map {PDFNum($_)} (2.22218, 2.22218, 2.22218));
|
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$csd->{' stream'}='';
|
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my %cc=();
|
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
foreach my $r (0,0x33,0x66,0x99,0xCC,0xFF) {
|
78
|
0
|
|
|
|
|
|
foreach my $g (0,0x33,0x66,0x99,0xCC,0xFF) {
|
79
|
0
|
|
|
|
|
|
foreach my $b (0,0x33,0x66,0x99,0xCC,0xFF) {
|
80
|
0
|
|
|
|
|
|
$csd->{' stream'}.=pack('CCC',$r,$g,$b);
|
81
|
0
|
|
|
|
|
|
$cc{sprintf('%02X%02X%02X',$r,$g,$b)}=1;
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
}
|
84
|
|
|
|
|
|
|
} # 0-215
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
foreach my $r (0,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF) {
|
87
|
0
|
|
|
|
|
|
$csd->{' stream'}.=pack('CCC',$r,$r,$r);
|
88
|
|
|
|
|
|
|
} # 216-231
|
89
|
0
|
|
|
|
|
|
foreach my $r (0,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF) {
|
90
|
0
|
|
|
|
|
|
$csd->{' stream'}.=pack('CCC',map { $_*255 } namecolor('!'.sprintf('%02X',$r).'FFFF'));
|
|
0
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} # 232-247
|
92
|
0
|
|
|
|
|
|
foreach my $r (0,0x22,0x44,0x66,0x88,0xAA,0xCC,0xEE) {
|
93
|
0
|
|
|
|
|
|
$csd->{' stream'}.=pack('CCC',map { $_*255 } namecolor('!'.sprintf('%02X',$r).'FF99'));
|
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} # 232-247
|
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
$csd->{' stream'}.="\x00" x 768;
|
97
|
0
|
|
|
|
|
|
$csd->{' stream'}=substr($csd->{' stream'},0,768);
|
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
$self->add_elements(PDFName('DeviceRGB'),PDFNum(255),$csd);
|
100
|
0
|
|
|
|
|
|
$self->{' csd'}=$csd;
|
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return($self);
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item $cs = PDF::API3::Compat::API2::Resource::ColorSpace::Indexed->new_api $api, $name
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns a indexed color-space object. This method is different from 'new' that
|
108
|
|
|
|
|
|
|
it needs an PDF::API3::Compat::API2-object rather than a Text::PDF::File-object.
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub new_api {
|
113
|
0
|
|
|
0
|
1
|
|
my ($class,$api,@opts)=@_;
|
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $obj=$class->new($api->{pdf},@opts);
|
116
|
0
|
|
|
|
|
|
$self->{' api'}=$api;
|
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
return($obj);
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1;
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__
|