| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ICC::Profile::Generic; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
122600
|
use strict; |
|
|
2
|
|
|
|
|
15
|
|
|
|
2
|
|
|
|
|
58
|
|
|
4
|
2
|
|
|
2
|
|
8
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
136
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.21; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# revised 2018-08-07 |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Copyright © 2004-2019 by William B. Birkett |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# add development directory |
|
13
|
2
|
|
|
2
|
|
503
|
use lib 'lib'; |
|
|
2
|
|
|
|
|
649
|
|
|
|
2
|
|
|
|
|
12
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# inherit from Shared |
|
16
|
2
|
|
|
2
|
|
262
|
use parent qw(ICC::Shared); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
15
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# create new generic tag object |
|
19
|
|
|
|
|
|
|
# parameters: () |
|
20
|
|
|
|
|
|
|
# parameters: (ref_to_attribute_hash) |
|
21
|
|
|
|
|
|
|
# returns: (ref_to_object) |
|
22
|
|
|
|
|
|
|
sub new { |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# get object class |
|
25
|
1
|
|
|
1
|
0
|
793
|
my $class = shift(); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# create empty generic object |
|
28
|
1
|
|
|
|
|
3
|
my $self = [ |
|
29
|
|
|
|
|
|
|
{}, # object header |
|
30
|
|
|
|
|
|
|
'' # data |
|
31
|
|
|
|
|
|
|
]; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# if single parameter is a scalar |
|
34
|
1
|
50
|
33
|
|
|
7
|
if (@_ == 1 && ! ref($_[0])) { |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# set object data |
|
37
|
0
|
|
|
|
|
0
|
$self->[1] = shift(); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# bless object |
|
42
|
1
|
|
|
|
|
2
|
bless($self, $class); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# return object reference |
|
45
|
1
|
|
|
|
|
3
|
return($self); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# create generic tag object from ICC profile |
|
50
|
|
|
|
|
|
|
# parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) |
|
51
|
|
|
|
|
|
|
# returns: (ref_to_object) |
|
52
|
|
|
|
|
|
|
sub new_fh { |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# get object class |
|
55
|
12
|
|
|
12
|
0
|
1513
|
my $class = shift(); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# create empty generic object |
|
58
|
12
|
|
|
|
|
31
|
my $self = [ |
|
59
|
|
|
|
|
|
|
{}, # object header |
|
60
|
|
|
|
|
|
|
'' # data |
|
61
|
|
|
|
|
|
|
]; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# verify 3 parameters |
|
64
|
12
|
50
|
|
|
|
31
|
(@_ == 3) or croak('wrong number of parameters'); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# read generic data from profile |
|
67
|
12
|
|
|
|
|
33
|
_readICCgeneric($self, @_); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# bless object |
|
70
|
12
|
|
|
|
|
38
|
bless($self, $class); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# return object reference |
|
73
|
12
|
|
|
|
|
156
|
return($self); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# writes generic tag object to ICC profile |
|
78
|
|
|
|
|
|
|
# parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) |
|
79
|
|
|
|
|
|
|
sub write_fh { |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# verify 4 parameters |
|
82
|
12
|
50
|
|
12
|
0
|
64
|
(@_ == 4) or croak('wrong number of parameters'); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# write generic data to profile |
|
85
|
12
|
|
|
|
|
37
|
goto &_writeICCgeneric; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# get tag size (for writing to profile) |
|
90
|
|
|
|
|
|
|
# returns: (tag_size) |
|
91
|
|
|
|
|
|
|
sub size { |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# get parameters |
|
94
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# return size |
|
97
|
0
|
|
|
|
|
0
|
return(length($self->[1])); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# get/set data string |
|
102
|
|
|
|
|
|
|
# parameters: ([data]) |
|
103
|
|
|
|
|
|
|
# returns: (data) |
|
104
|
|
|
|
|
|
|
sub data { |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# get object reference |
|
107
|
0
|
|
|
0
|
0
|
0
|
my $self = shift(); |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# if parameter supplied |
|
110
|
0
|
0
|
|
|
|
0
|
if (@_) { |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# save it |
|
113
|
0
|
|
|
|
|
0
|
$self->[1] = shift(); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# return text string |
|
118
|
0
|
|
|
|
|
0
|
return($self->[1]); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# print object contents to string |
|
123
|
|
|
|
|
|
|
# format is an array structure |
|
124
|
|
|
|
|
|
|
# parameter: ([format]) |
|
125
|
|
|
|
|
|
|
# returns: (string) |
|
126
|
|
|
|
|
|
|
sub sdump { |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# get parameters |
|
129
|
0
|
|
|
0
|
1
|
0
|
my ($self, $p) = @_; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# local variables |
|
132
|
0
|
|
|
|
|
0
|
my ($s, $fmt); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# resolve parameter to an array reference |
|
135
|
0
|
0
|
|
|
|
0
|
$p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : []; |
|
|
|
0
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# get format string |
|
138
|
0
|
0
|
0
|
|
|
0
|
$fmt = defined($p->[0]) && ! ref($p->[0]) ? $p->[0] : 'undef'; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# set string to object ID |
|
141
|
0
|
|
|
|
|
0
|
$s = sprintf("'%s' object, (0x%x)\n", ref($self), $self); |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# return |
|
144
|
0
|
|
|
|
|
0
|
return($s); |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# read generic tag from ICC profile |
|
149
|
|
|
|
|
|
|
# parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) |
|
150
|
|
|
|
|
|
|
sub _readICCgeneric { |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# get parameters |
|
153
|
12
|
|
|
12
|
|
23
|
my ($self, $parent, $fh, $tag) = @_; |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# save tag signature |
|
156
|
12
|
|
|
|
|
29
|
$self->[0]{'signature'} = $tag->[0]; |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# seek start of tag |
|
159
|
12
|
|
|
|
|
120
|
seek($fh, $tag->[1], 0); |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# read tag |
|
162
|
12
|
|
|
|
|
3903
|
read($fh, $self->[1], $tag->[2]); |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# write generic tag to ICC profile |
|
167
|
|
|
|
|
|
|
# parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) |
|
168
|
|
|
|
|
|
|
sub _writeICCgeneric { |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# get parameters |
|
171
|
12
|
|
|
12
|
|
25
|
my ($self, $parent, $fh, $tag) = @_; |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# seek start of tag |
|
174
|
12
|
|
|
|
|
214
|
seek($fh, $tag->[1], 0); |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# write tag |
|
177
|
12
|
|
|
|
|
4031
|
print $fh $self->[1]; |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
1; |