line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ICC::Profile::clro; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
122705
|
use strict; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
132
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.12; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# revised 2018-08-07 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Copyright © 2004-2019 by William B. Birkett |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# add development directory |
13
|
2
|
|
|
2
|
|
852
|
use lib 'lib'; |
|
2
|
|
|
|
|
1221
|
|
|
2
|
|
|
|
|
12
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# inherit from Shared |
16
|
2
|
|
|
2
|
|
251
|
use parent qw(ICC::Shared); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# create new clro tag object |
19
|
|
|
|
|
|
|
# parameters: ([ref_to_seq_array]) |
20
|
|
|
|
|
|
|
# returns: (ref_to_object) |
21
|
|
|
|
|
|
|
sub new { |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# get object class |
24
|
2
|
|
|
2
|
0
|
1471
|
my $class = shift(); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# create empty clro object |
27
|
2
|
|
|
|
|
6
|
my $self = [ |
28
|
|
|
|
|
|
|
{}, # object header |
29
|
|
|
|
|
|
|
[] # colorant sequence array |
30
|
|
|
|
|
|
|
]; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# if parameter supplied |
33
|
2
|
100
|
|
|
|
9
|
if (@_) { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# make new clro tag from colorant sequence array |
36
|
1
|
|
|
|
|
5
|
_newICCclro($self, @_); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# bless object |
41
|
2
|
|
|
|
|
3
|
bless($self, $class); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# return object reference |
44
|
2
|
|
|
|
|
6
|
return($self); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# create clro tag object from ICC profile |
49
|
|
|
|
|
|
|
# parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) |
50
|
|
|
|
|
|
|
# returns: (ref_to_object) |
51
|
|
|
|
|
|
|
sub new_fh { |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# get object class |
54
|
1
|
|
|
1
|
0
|
9
|
my $class = shift(); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# create empty clro object |
57
|
1
|
|
|
|
|
4
|
my $self = [ |
58
|
|
|
|
|
|
|
{}, # object header |
59
|
|
|
|
|
|
|
[] # colorant sequence array |
60
|
|
|
|
|
|
|
]; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# verify 3 parameters |
63
|
1
|
50
|
|
|
|
4
|
(@_ == 3) or croak('wrong number of parameters'); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# read clro data from profile |
66
|
1
|
|
|
|
|
5
|
_readICCclro($self, @_); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# bless object |
69
|
1
|
|
|
|
|
4
|
bless($self, $class); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# return object reference |
72
|
1
|
|
|
|
|
11
|
return($self); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# writes clro tag object to ICC profile |
77
|
|
|
|
|
|
|
# parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) |
78
|
|
|
|
|
|
|
sub write_fh { |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# verify 4 parameters |
81
|
1
|
50
|
|
1
|
0
|
812
|
(@_ == 4) or croak('wrong number of parameters'); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# write clro data to profile |
84
|
1
|
|
|
|
|
6
|
goto &_writeICCclro; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# get tag size (for writing to profile) |
89
|
|
|
|
|
|
|
# returns: (tag_size) |
90
|
|
|
|
|
|
|
sub size { |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# get parameters |
93
|
1
|
|
|
1
|
0
|
1058
|
my ($self) = @_; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# return size |
96
|
1
|
|
|
|
|
3
|
return(12 + @{$self->[1]}); |
|
1
|
|
|
|
|
5
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# get/set colorant sequence |
101
|
|
|
|
|
|
|
# parameters: ([ref_to_seq_array]) |
102
|
|
|
|
|
|
|
# returns: (ref_to_seq_array) |
103
|
|
|
|
|
|
|
sub sequence { |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# get object reference |
106
|
2
|
|
|
2
|
0
|
379
|
my $self = shift(); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# if parameter supplied |
109
|
2
|
100
|
|
|
|
7
|
if (@_) { |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# get ref to sequence array |
112
|
1
|
|
|
|
|
3
|
my $seq = shift(); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# initialize counter |
115
|
1
|
|
|
|
|
2
|
my $i = 0; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# verify sequence array |
118
|
1
|
50
|
|
|
|
2
|
(@{$seq} == grep {$_ == $i++} sort {$a <=> $b} @{$seq}) or croak('bad sequence array'); |
|
1
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
5
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# save array |
121
|
1
|
|
|
|
|
7
|
$self->[1] = $seq; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# return text string |
126
|
2
|
|
|
|
|
5
|
return($self->[1]); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# print object contents to string |
131
|
|
|
|
|
|
|
# format is an array structure |
132
|
|
|
|
|
|
|
# parameter: ([format]) |
133
|
|
|
|
|
|
|
# returns: (string) |
134
|
|
|
|
|
|
|
sub sdump { |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# get parameters |
137
|
0
|
|
|
0
|
1
|
0
|
my ($self, $p) = @_; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# local variables |
140
|
0
|
|
|
|
|
0
|
my ($s, $fmt); |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# resolve parameter to an array reference |
143
|
0
|
0
|
|
|
|
0
|
$p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : []; |
|
|
0
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# get format string |
146
|
0
|
0
|
0
|
|
|
0
|
$fmt = defined($p->[0]) && ! ref($p->[0]) ? $p->[0] : 'undef'; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# set string to object ID |
149
|
0
|
|
|
|
|
0
|
$s = sprintf("'%s' object, (0x%x)\n", ref($self), $self); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# return |
152
|
0
|
|
|
|
|
0
|
return($s); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# make new clro tag from colorant sequence array |
157
|
|
|
|
|
|
|
# parameters: (ref_to_object, ref_to_seq_array) |
158
|
|
|
|
|
|
|
sub _newICCclro { |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# get parameters |
161
|
1
|
|
|
1
|
|
3
|
my ($self, $seq) = @_; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# initialize counter |
164
|
1
|
|
|
|
|
2
|
my $i = 0; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# verify sequence array |
167
|
1
|
50
|
|
|
|
3
|
(@{$seq} == grep {$_ == $i++} sort {$a <=> $b} @{$seq}) or croak('bad sequence array'); |
|
1
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
4
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# copy array |
170
|
1
|
|
|
|
|
2
|
$self->[1] = [@{$seq}]; |
|
1
|
|
|
|
|
4
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# read clro tag from ICC profile |
175
|
|
|
|
|
|
|
# parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) |
176
|
|
|
|
|
|
|
sub _readICCclro { |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# get parameters |
179
|
1
|
|
|
1
|
|
4
|
my ($self, $parent, $fh, $tag) = @_; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# local variables |
182
|
1
|
|
|
|
|
2
|
my ($buf, $cnt); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# save tag signature |
185
|
1
|
|
|
|
|
4
|
$self->[0]{'signature'} = $tag->[0]; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# seek start of tag |
188
|
1
|
|
|
|
|
51
|
seek($fh, $tag->[1], 0); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# read tag type signature and colorant count |
191
|
1
|
|
|
|
|
14
|
read($fh, $buf, 12); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# unpack colorant count |
194
|
1
|
|
|
|
|
7
|
$cnt = unpack('x8 N', $buf); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# read colorant array |
197
|
1
|
|
|
|
|
3
|
read($fh, $buf, $cnt); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# unpack colorant array |
200
|
1
|
|
|
|
|
5
|
$self->[1] = [unpack('C*', $buf)]; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# write clro tag to ICC profile |
205
|
|
|
|
|
|
|
# parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) |
206
|
|
|
|
|
|
|
sub _writeICCclro { |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# get parameters |
209
|
1
|
|
|
1
|
|
4
|
my ($self, $parent, $fh, $tag) = @_; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# seek start of tag |
212
|
1
|
|
|
|
|
10
|
seek($fh, $tag->[1], 0); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# write tag |
215
|
1
|
|
|
|
|
4
|
print $fh pack('a4 x4 N C*', 'clro', scalar(@{$self->[1]}), @{$self->[1]}); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
13
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
1; |