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