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: Indexed.pm,v 2.0 2005/11/16 02:18:14 areibens Exp $
|
31
|
|
|
|
|
|
|
#
|
32
|
|
|
|
|
|
|
#=======================================================================
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package PDF::API3::Compat::API2::Resource::ColorSpace::Indexed;
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
BEGIN {
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
8
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
39
|
1
|
|
|
1
|
|
6
|
use vars qw(@ISA $VERSION);
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
499
|
|
40
|
1
|
|
|
1
|
|
5748
|
use PDF::API3::Compat::API2::Resource::ColorSpace;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
41
|
1
|
|
|
1
|
|
9
|
use PDF::API3::Compat::API2::Basic::PDF::Utils;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
143
|
|
42
|
1
|
|
|
1
|
|
6
|
use PDF::API3::Compat::API2::Util;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
232
|
|
43
|
1
|
|
|
1
|
|
7
|
use Math::Trig;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
332
|
|
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
23
|
@ISA = qw( PDF::API3::Compat::API2::Resource::ColorSpace );
|
46
|
1
|
|
|
|
|
46
|
( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.0 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2005/11/16 02:18:14 $
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
}
|
49
|
1
|
|
|
1
|
|
8
|
no warnings qw[ deprecated recursion uninitialized ];
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
664
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item $cs = PDF::API3::Compat::API2::Resource::ColorSpace::Indexed->new $pdf, $key, %parameters
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Returns a new colorspace object.
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub new {
|
58
|
0
|
|
|
0
|
1
|
|
my ($class,$pdf,$key,%opts)=@_;
|
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
$class = ref $class if ref $class;
|
61
|
0
|
|
|
|
|
|
$self=$class->SUPER::new($pdf,$key,%opts);
|
62
|
0
|
0
|
|
|
|
|
$pdf->new_obj($self) unless($self->is_obj($pdf));
|
63
|
0
|
|
|
|
|
|
$self->{' apipdf'}=$pdf;
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->add_elements(PDFName('Indexed'));
|
66
|
0
|
|
|
|
|
|
$self->type('Indexed');
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return($self);
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item $cs = PDF::API3::Compat::API2::Resource::ColorSpace::Indexed->new_api $api, $name
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns a indexed color-space object. This method is different from 'new' that
|
74
|
|
|
|
|
|
|
it needs an PDF::API3::Compat::API2-object rather than a Text::PDF::File-object.
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub new_api {
|
79
|
0
|
|
|
0
|
1
|
|
my ($class,$api,@opts)=@_;
|
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $obj=$class->new($api->{pdf},@opts);
|
82
|
0
|
|
|
|
|
|
$self->{' api'}=$api;
|
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return($obj);
|
85
|
|
|
|
|
|
|
}
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub enumColors {
|
88
|
0
|
|
|
0
|
0
|
|
my $self=shift @_;
|
89
|
0
|
|
|
|
|
|
my %col=();
|
90
|
0
|
|
|
|
|
|
foreach my $n (0..255) {
|
91
|
0
|
|
|
|
|
|
my $k='#'.uc(unpack('H*',substr($self->{' csd'}->{' stream'},$n*3,3)));
|
92
|
0
|
0
|
|
|
|
|
$col{$k}=$n unless(defined $col{$k});
|
93
|
|
|
|
|
|
|
}
|
94
|
0
|
|
|
|
|
|
return(%col);
|
95
|
|
|
|
|
|
|
}
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub nameColor {
|
98
|
0
|
|
|
0
|
0
|
|
my $self=shift @_;
|
99
|
0
|
|
|
|
|
|
my $n=shift @_;
|
100
|
0
|
|
|
|
|
|
my %col=();
|
101
|
0
|
|
|
|
|
|
my $k='#'.uc(unpack('H*',substr($self->{' csd'}->{' stream'},$n*3,3)));
|
102
|
0
|
|
|
|
|
|
return($k);
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub resolveNearestRGB {
|
106
|
0
|
|
|
0
|
0
|
|
my $self=shift @_;
|
107
|
0
|
|
|
|
|
|
my ($r,$g,$b)=@_; # need to be in 0-255
|
108
|
0
|
|
|
|
|
|
my $c=0;
|
109
|
0
|
|
|
|
|
|
my $w=768**2;
|
110
|
0
|
|
|
|
|
|
foreach my $n (0..255) {
|
111
|
0
|
|
|
|
|
|
my @e=unpack('C*',substr($self->{' csd'}->{' stream'},$n*3,3));
|
112
|
0
|
|
|
|
|
|
my $d=($e[0]-$r)**2 + ($e[1]-$g)**2 + ($e[2]-$b)**2;
|
113
|
0
|
0
|
|
|
|
|
if($d<$w) { $c=$n; $w=$d; }
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
}
|
115
|
0
|
|
|
|
|
|
return($c);
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1;
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__END__
|