blib/lib/ICC/Profile/vcgt.pm

filter: Statementstmt 11.3% 19 / 168 Branchbran 1.2% 1 / 80 Conditioncond 0.0% 0 / 45 MC/DCmcdc 0.0% 0 / 27 Subroutinesub 31.2% 5 / 16 Podpod 12.5% 1 / 8 totaltotal 7.5% 26 / 344 CC 63 SCAR 46.7
CC
63
Cov
7%
_writeICCvcgt
306.0
new
132.5
transform
42.0
CRAP 106.5
« blib/lib/ICC/Profile/para.pm ↑ Summary blib/lib/ICC/Profile/pseq.pm »
1 package ICC::Profile::vcgt;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = 0.12;
7  
8 # revised 2016-05-17
9 #
10 # Copyright © 2004-2018 by William B. Birkett
11  
12 # add development directory
13 2 ▶use lib 'lib';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # inherit from Shared
16 2 ▶use parent qw(ICC::Shared);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # create new vcgt tag object
19 # parameters: ()
20 # parameters: (ref_to_array_of_curv_objects)
21 # parameters: (ref_to_3x3_parameter_array)
22 # returns: (ref_to_object)
23 sub new {
24  
25 # get object class
26 1 ▶ my $class = shift();
Subroutine new: called CC=13 SCAR=48.9
Pod undocumented
27  
28 # create empty vcgt object
29 1 my $self = [
30 {}, # object header
31 [[]] # array
32 ];
33  
34 # if parameter supplied
35 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
36
37 # if one parameter, a reference to an array of 'curv' objects
38 0 ▶ if (@_ == 1 && ref($_[0]) eq 'ARRAY' && @{$_[0]} == grep {UNIVERSAL::isa($_, 'ICC::Profile::curv')} @{$_[0]}) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'ARRAY' and @{$_[0];} == grep({UNIVERSAL::isa($_, 'ICC::Profile::curv');} @{$_[0];})) { } 0 0 0
elsif (@_ == 1 and ref $_[0] eq 'ARRAY' and @{$_[0];} == grep({ref $_ eq 'ARRAY';} @{$_[0];})) { } 0 0 0
Condition0%0/6
@_ == 1 and ref $_[0] eq "ARRAY" and @{$_[0];} == grep({UNIVERSAL::isa($_, "ICC::Profile::curv");} @{$_[0];})
!ll&&!rl&&r
000
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
@_ == 1 and ref $_[0] eq "ARRAY" and @{$_[0];} == grep({UNIVERSAL::isa($_, "ICC::Profile::curv");} @{$_[0];})
@_ == 1 ref $_[0] eq "ARRAY" @{$_[0];} == grep({UNIVERSAL::isa($_, "ICC::Profile::curv");} @{$_[0];})
Truth table0%0/4
A and B and C
A= @_ == 1B= ref $_[0] eq "ARRAY"C= @{$_[0];} == grep({UNIVERSAL::isa($_, "ICC::Profile::curv");} @{$_[0];})
ABCresult
0XX0
10X0
1100
1111
39
40 # verify one or three objects
41 0 ▶ (@{$_[0]} == 1 || @{$_[0]} == 3) || croak('array must contain one or three \'curv\' objects');
Branch: 1 branch
BranchTrueFalseTotal
@{$_[0];} == 1 or @{$_[0];} == 3 or croak("array must contain one or three 'curv' objects") 0 0 0
Condition0%0/3
@{$_[0];} == 1 or @{$_[0];} == 3
l!l&&r!l&&!r
000
MC/DC0%0/2
@{$_[0];} == 1 or @{$_[0];} == 3
@{$_[0];} == 1 @{$_[0];} == 3
Truth table0%0/3
A or B
A= @{$_[0];} == 1B= @{$_[0];} == 3
ABresult
1X1
011
000
42
43 # copy array
44 0 $self->[1] = [@{shift()}];
45
46 # if one parameter, a reference to a 2-D array
47 0 ▶ } elsif (@_ == 1 && (ref($_[0]) eq 'ARRAY') && @{$_[0]} == grep {ref() eq 'ARRAY'} @{$_[0]}) {
Condition0%0/6
@_ == 1 and ref $_[0] eq "ARRAY" and @{$_[0];} == grep({ref $_ eq "ARRAY";} @{$_[0];})
!ll&&!rl&&r
000
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
@_ == 1 and ref $_[0] eq "ARRAY" and @{$_[0];} == grep({ref $_ eq "ARRAY";} @{$_[0];})
@_ == 1 ref $_[0] eq "ARRAY" @{$_[0];} == grep({ref $_ eq "ARRAY";} @{$_[0];})
Truth table0%0/4
A and B and C
A= @_ == 1B= ref $_[0] eq "ARRAY"C= @{$_[0];} == grep({ref $_ eq "ARRAY";} @{$_[0];})
ABCresult
0XX0
10X0
1100
1111
48
49 # verify 3x3 scalar array
50 0 ▶ (3 == @{$_[0]} && 3 == @{$_[0][0]} && 3 == grep {! ref()} @{$_[0][0]}) || croak('array must contain 3x3 scalar array');
Branch: 1 branch
BranchTrueFalseTotal
3 == @{$_[0];} and 3 == @{$_[0][0];} and 3 == grep({not ref $_;} @{$_[0][0];}) or croak("array must contain 3x3 scalar array") 0 0 0
Condition0%0/6
3 == @{$_[0];} and 3 == @{$_[0][0];} and 3 == grep({not ref $_;} @{$_[0][0];})
!ll&&!rl&&r
000
3 == @{$_[0];} and 3 == @{$_[0][0];}
!ll&&!rl&&r
000
MC/DC0%0/3
3 == @{$_[0];} and 3 == @{$_[0][0];} and 3 == grep({not ref $_;} @{$_[0][0];})
3 == @{$_[0];} 3 == @{$_[0][0];} 3 == grep({not ref $_;} @{$_[0][0];})
Truth table0%0/4
A and B and C
A= 3 == @{$_[0];}B= 3 == @{$_[0][0];}C= 3 == grep({not ref $_;} @{$_[0][0];})
ABCresult
0XX0
10X0
1100
1111
51
52 # copy array
53 0 $self->[1] = Storable::dclone(shift());
54
55 } else {
56
57 # error
58 0 croak('invalid parameter(s) for new \'vcgt\' object');
59
60 }
61
62 }
63  
64 # bless object
65 1 bless($self, $class);
66  
67 # return object reference
68 1 return($self);
69  
70 }
71  
72 # create vcgt tag object from ICC profile
73 # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry)
74 # returns: (ref_to_object)
75 sub new_fh {
76  
77 # get object class
78 0 ▶ my $class = shift();
Subroutine new_fh: not called CC=2 SCAR=17.9
Pod undocumented
79  
80 0 my $self = [
81 {}, # object header
82 [[]] # array
83 ];
84  
85 # verify 3 parameters
86 0 ▶ (@_ == 3) || croak('wrong number of parameters');
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or croak("wrong number of parameters") 0 0 0
87  
88 # read vcgt data from profile
89 0 _readICCvcgt($self, @_);
90  
91 # bless object
92 0 bless($self, $class);
93  
94 # return object reference
95 0 return($self);
96  
97 }
98  
99 # writes vcgt tag object to ICC profile
100 # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry)
101 sub write_fh {
102  
103 # get tag reference
104 0 ▶ my $self = shift();
Subroutine write_fh: not called CC=2 SCAR=17.9
Pod undocumented
105  
106 # verify 3 parameters
107 0 ▶ (@_ == 3) || croak('wrong number of parameters');
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or croak("wrong number of parameters") 0 0 0
108  
109 # write vcgt data to profile
110 0 _writeICCvcgt($self, @_);
111  
112 }
113  
114 # get tag size (for writing to profile)
115 # returns: (tag_size)
116 sub size {
117  
118 # get parameters
119 0 ▶ my ($self) = @_;
Subroutine size: not called CC=4 SCAR=30.0
Pod undocumented
120  
121 # local variables
122 0 my ($channels, $count, $size);
123  
124 # if table
125 0 ▶ if (UNIVERSAL::isa($self->[1][0], 'ICC::Profile::curv') && @{$self->[1][0]->array()} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($self->[1][0], 'ICC::Profile::curv') and @{$self->[1][0]->array;} > 1) { } 0 0 0
Condition0%0/3
UNIVERSAL::isa($self->[1][0], "ICC::Profile::curv") and @{$self->[1][0]->array;} > 1
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($self->[1][0], "ICC::Profile::curv") and @{$self->[1][0]->array;} > 1
UNIVERSAL::isa($self->[1][0], "ICC::Profile::curv") @{$self->[1][0]->array;} > 1
Truth table0%0/3
A and B
A= UNIVERSAL::isa($self->[1][0], "ICC::Profile::curv")B= @{$self->[1][0]->array;} > 1
ABresult
0X0
100
111
126
127 # get channels
128 0 $channels = @{$self->[1]};
129
130 # get entryCount
131 0 $count = @{$self->[1][0]->array()};
132
133 # get entrySize
134 0 ▶ $size = defined($self->[0]{'entrySize'}) ? $self->[0]{'entrySize'} : 2;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[0]{'entrySize'} ? : 0 0 0
135
136 # return size
137 0 return(18 + $channels * $count * $size);
138
139 # if function
140 } else {
141
142 # return size
143 0 return(48);
144
145 }
146
147 }
148  
149 # get/set array reference
150 # parameters: ([ref_to_array])
151 # returns: (ref_to_array)
152 sub array {
153  
154 # get object reference
155 0 ▶ my $self = shift();
Subroutine array: not called CC=3 SCAR=24.8
Pod undocumented
156  
157 # if parameter
158 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
159
160 # verify array reference
161 0 ▶ (ref($_[0]) eq 'ARRAY') || croak('not an array reference');
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq "ARRAY" or croak("not an array reference") 0 0 0
162
163 # set array reference
164 0 $self->[1] = shift();
165
166 }
167
168 # return array reference
169 0 return($self->[1]);
170  
171 }
172  
173 # compute curve function
174 # parameters: (array_input_values -or- ref_to_input_array)
175 # returns: (array_output_values -or- ref_to_output-array)
176 sub transform {
177
178 # get object reference
179 0 ▶ my ($self) = shift();
Subroutine transform: not called CC=6 SCAR=37.4
Pod undocumented
180
181 # if one input parameter, an array reference
182 0 ▶ if (@_ == 1 && ref($_[0]) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'ARRAY') { } 0 0 0
elsif (@_ == 1 and UNIVERSAL::isa($_[0], 'Math::Matrix')) { } 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1 ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
183
184 # transform the array structure
185 0 _crawl($self, 0, $_[0], my $out = []);
186
187 # return output reference
188 0 return($out);
189
190 # if one input parameter, a Math::Matrix object
191 ▶ } elsif (@_ == 1 && UNIVERSAL::isa($_[0], 'Math::Matrix')) {
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "Math::Matrix")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "Math::Matrix")
@_ == 1 UNIVERSAL::isa($_[0], "Math::Matrix")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "Math::Matrix")
ABresult
0X0
100
111
192
193 # transform the array structure
194 0 _crawl($self, 0, $_[0], my $out = bless([], 'Math::Matrix'));
195
196 # return output reference
197 0 return($out);
198
199 } else {
200
201 # if caller expects array
202 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
203
204 # return array
205 0 return(_transform($self, 0, @_));
206
207 } else {
208
209 # transform array
210 0 my @out = _transform($self, 0, @_);
211
212 # return scalar
213 0 return($out[0]);
214
215 }
216
217 }
218  
219 }
220  
221 # compute inverse curve function
222 # parameters: (array_input_values -or- ref_to_input_array)
223 # returns: (array_output_values -or- ref_to_output-array)
224 sub inverse {
225
226 # get object reference
227 0 ▶ my ($self) = shift();
Subroutine inverse: not called CC=6 SCAR=37.4
Pod undocumented
228
229 # if one input parameter, an array reference
230 0 ▶ if (@_ == 1 && ref($_[0]) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'ARRAY') { } 0 0 0
elsif (@_ == 1 and UNIVERSAL::isa($_[0], 'Math::Matrix')) { } 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1 ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
231
232 # transform the array structure
233 0 _crawl($self, 1, $_[0], my $out = []);
234
235 # return output reference
236 0 return($out);
237
238 # if one input parameter, a Math::Matrix object
239 ▶ } elsif (@_ == 1 && UNIVERSAL::isa($_[0], 'Math::Matrix')) {
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "Math::Matrix")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "Math::Matrix")
@_ == 1 UNIVERSAL::isa($_[0], "Math::Matrix")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "Math::Matrix")
ABresult
0X0
100
111
240
241 # transform the array structure
242 0 _crawl($self, 1, $_[0], my $out = bless([], 'Math::Matrix'));
243
244 # return output reference
245 0 return($out);
246
247 } else {
248
249 # if caller expects array
250 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
251
252 # return array
253 0 return(_transform($self, 1, @_));
254
255 } else {
256
257 # transform array
258 0 my @out = _transform($self, 1, @_);
259
260 # return scalar
261 0 return($out[0]);
262
263 }
264
265 }
266
267 }
268  
269 # print object contents to string
270 # format is an array structure
271 # parameter: ([format])
272 # returns: (string)
273 sub sdump {
274  
275 # get parameters
276 0 ▶ my ($self, $p) = @_;
Subroutine sdump: not called CC=5 SCAR=34.0
Pod documented
277  
278 # local variables
279 0 my ($s, $fmt);
280  
281 # resolve parameter to an array reference
282 0 ▶ $p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : [];
Branch: 2 branches
BranchTrueFalseTotal
defined $p ? : 0 0 0
ref $p eq 'ARRAY' ? : 0 0 0
283  
284 # get format string
285 0 ▶ $fmt = defined($p->[0]) && ! ref($p->[0]) ? $p->[0] : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $p->[0] && !ref($p->[0]) ? : 0 0 0
Condition0%0/3
defined $p->[0] and not ref $p->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->[0] and not ref $p->[0]
defined $p->[0] not ref $p->[0]
Truth table0%0/3
A and not(B)
A= defined $p->[0]B= not ref $p->[0]
ABresult
0X0
100
111
286  
287 # set string to object ID
288 0 $s = sprintf("'%s' object, (0x%x)\n", ref($self), $self);
289  
290 # return
291 0 return($s);
292  
293 }
294  
295 # recursive transform
296 # array structure is traversed until scalar arrays are found and transformed
297 # parameters: (object_reference, direction, input_array_reference, output_array_reference)
298 sub _crawl {
299
300 # get parameters
301 0 ▶ my ($self, $dir, $in, $out) = @_;
Subroutine _crawl: not called CC=4 SCAR=30.0
302
303 # if input is a vector (reference to a scalar array)
304 0 ▶ if (@{$in} == grep {! ref()} @{$in}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$in;} == grep({not ref $_;} @{$in;})) { } 0 0 0
305
306 # transform input vector and copy to output
307 0 @{$out} = _transform($self, $dir, @{$in});
308
309 } else {
310
311 # for each input element
312 0 for my $i (0 .. $#{$in}) {
313
314 # if an array reference
315 0 ▶ if (ref($in->[$i]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $in->[$i] eq 'ARRAY') { } 0 0 0
316
317 # transform next level
318 0 _crawl($self, $dir, $in->[$i], $out->[$i] = []);
319
320 } else {
321
322 # error
323 0 croak('invalid transform input');
324
325 }
326
327 }
328
329 }
330
331 }
332  
333 # transform input value array (vector)
334 # direction: 0 - normal, 1 - inverse
335 # parameters: (object_reference, direction, input_value_array)
336 # returns: (output_value_array)
337 sub _transform {
338  
339 # get parameters
340 0 ▶ my ($self, $dir, @in) = @_;
Subroutine _transform: not called CC=6 SCAR=37.4
341  
342 # local variables
343 0 my (@out);
344  
345 # verify inputs are all scalars
346 0 ▶ (@in == grep {! ref()} @in) || croak('invalid transform input');
Branch: 1 branch
BranchTrueFalseTotal
@in == grep({not ref $_;} @in) or croak("invalid transform input") 0 0 0
347  
348 # verify number of inputs equals number of channels
349 0 ▶ (@in == @{$self->[1]}) || croak('wrong number of input values');
Branch: 1 branch
BranchTrueFalseTotal
@in == @{$self->[1];} or croak("wrong number of input values") 0 0 0
350  
351 # for each channel
352 0 for my $i (0 .. $#{$self->[1]}) {
353
354 # if 'curv' object
355 0 ▶ if (UNIVERSAL::isa($self->[1][$i], 'ICC::Profile::curv')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($self->[1][$i], 'ICC::Profile::curv')) { } 0 0 0
356
357 # transform using 'curv' method
358 0 $out[$i] = $self->[1][$i]->_transform($dir, $in[$i]);
359
360 } else {
361
362 # if normal direction
363 0 ▶ if ($dir == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dir == 0) { } 0 0 0
364
365 # forward transform using formula (out = min + (max - min) * input^gamma)
366 0 $out[$i] = $self->[1][$i][1] + ($self->[1][$i][2] - $self->[1][$i][1]) * $in[$i]**$self->[1][$i][0];
367
368 } else {
369
370 # reverse transform using formula (out = ((input - min)/(max - min))^(1/gamma))
371 0 $out[$i] = (($in[$i] - $self->[1][$i][1])/($self->[1][$i][2] - $self->[1][$i][1]))**(1/$self->[1][$i][0]);
372
373 }
374
375 }
376
377 }
378  
379 # return output array
380 0 return(@out);
381  
382 }
383  
384 # read vcgt tag from ICC profile
385 # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry)
386 sub _readICCvcgt {
387  
388 # get parameters
389 0 ▶ my ($self, $parent, $fh, $tag) = @_;
Subroutine _readICCvcgt: not called CC=6 SCAR=37.4
390  
391 # local variables
392 0 my ($tagType, $buf, $channels, $count, $size, @table);
393  
394 # save tag signature
395 0 $self->[0]{'signature'} = $tag->[0];
396  
397 # seek start of tag
398 0 seek($fh, $tag->[1], 0);
399  
400 # read first 12 bytes
401 0 read($fh, $buf, 12);
402  
403 # unpack tagType (0 = cmVideoCardGammaTableType, 1 = cmVideoCardGammaFormulaType)
404 0 $tagType = unpack('x8 N', $buf);
405  
406 # if table
407 0 ▶ if ($tagType == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tagType == 0) { } 0 0 0
elsif ($tagType == 1) { } 0 0 0
408
409 # read 6 bytes
410 0 read($fh, $buf, 6);
411
412 # unpack channels, entryCount, entrySize
413 0 ($channels, $count, $size) = unpack('n3', $buf);
414
415 # save entrySize in header hash
416 0 $self->[0]{'entrySize'} = $size;
417
418 # for each channel (gray or RGB)
419 0 for my $i (0 .. $channels - 1) {
420
421 # read table data
422 0 read($fh, $buf, $count * $size);
423
424 # if 8-bit
425 0 ▶ if ($size == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size == 1) { } 0 0 0
426
427 # unpack table
428 0 @table = unpack('C*', $buf);
429
430 # save as 'curv' object
431 0 $self->[1][$i] = ICC::Profile::curv->new([map {$_/255} @table]);
432
433 # else 16-bit
434 } else {
435
436 # unpack table
437 0 @table = unpack('n*', $buf);
438
439 # save as 'curv' object
440 0 $self->[1][$i] = ICC::Profile::curv->new([map {$_/65535} @table]);
441
442 }
443
444 }
445
446 # if formula
447 } elsif ($tagType == 1) {
448
449 # for each RGB
450 0 for my $i (0 .. 2) {
451
452 # read 12 bytes
453 0 read($fh, $buf, 12);
454
455 # unpack gamma, min, max (s15Fixed16Number values)
456 0 $self->[1][$i] = [ICC::Shared::s15f162v(unpack('N3', $buf))];
457
458 }
459
460 } else {
461
462 # error
463 0 croak('invalid \'vcgt\' tagType');
464
465 }
466
467 }
468  
469 # write vcgt tag to ICC profile
470 # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry)
471 sub _writeICCvcgt {
472  
473 # get parameters
474 0 ▶ my ($self, $parent, $fh, $tag) = @_;
Subroutine _writeICCvcgt: not called CC=17 SCAR=57.2
475  
476 # local variables
477 0 my ($tagType, $channels, $count, $size, @table, $gamma);
478  
479 # seek start of tag
480 0 seek($fh, $tag->[1], 0);
481  
482 # determine tagType (0 = cmVideoCardGammaTableType, 1 = cmVideoCardGammaFormulaType)
483 0 ▶ $tagType = (UNIVERSAL::isa($self->[1][0], 'ICC::Profile::curv') && @{$self->[1][0]->array()} > 1) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($self->[1][0], 'ICC::Profile::curv') && @{$self->[1][0]->array;} > 1 ? : 0 0 0
Condition0%0/3
UNIVERSAL::isa($self->[1][0], "ICC::Profile::curv") and @{$self->[1][0]->array;} > 1
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($self->[1][0], "ICC::Profile::curv") and @{$self->[1][0]->array;} > 1
UNIVERSAL::isa($self->[1][0], "ICC::Profile::curv") @{$self->[1][0]->array;} > 1
Truth table0%0/3
A and B
A= UNIVERSAL::isa($self->[1][0], "ICC::Profile::curv")B= @{$self->[1][0]->array;} > 1
ABresult
0X0
100
111
484  
485 # write signature and tagType
486 0 print $fh pack('a4 x4 N', 'vcgt', $tagType);
487  
488 # if table
489 0 ▶ if ($tagType == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagType == 0) { } 0 0 0
490
491 # get channels
492 0 $channels = @{$self->[1]};
493
494 # get entryCount
495 0 $count = @{$self->[1][0]->array()};
496
497 # if entrySize is 8-bit
498 0 ▶ $size = (defined($self->[0]{'entrySize'}) && $self->[0]{'entrySize'} == 1) ? 1 : 2;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[0]{'entrySize'} && $self->[0]{'entrySize'} == 1 ? : 0 0 0
Condition0%0/3
defined $self->[0]{"entrySize"} and $self->[0]{"entrySize"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->[0]{"entrySize"} and $self->[0]{"entrySize"} == 1
defined $self->[0]{"entrySize"} $self->[0]{"entrySize"} == 1
Truth table0%0/3
A and B
A= defined $self->[0]{"entrySize"}B= $self->[0]{"entrySize"} == 1
ABresult
0X0
100
111
499
500 # write channels, entryCount, entrySize
501 0 print $fh pack('n3', $channels, $count, $size);
502
503 # for each channel (gray or RGB)
504 0 for my $i (0 .. $channels - 1) {
505
506 # if 8-bit
507 0 ▶ if ($size == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size == 1) { } 0 0 0
508
509 # write table limiting values, converting to 8-bit, adding 0.5 to round
510 0 ▶ print $fh pack('C*', map {$_ < 0 ? 0 : ($_ > 1 ? 255 : $_ * 255 + 0.5)} @{$self->[1][$i]->array()});
Branch: 2 branches
BranchTrueFalseTotal
$_ < 0 ? : 0 0 0
$_ > 1 ? : 0 0 0
511
512 # else 16-bit
513 } else {
514
515 # write table limiting values, converting to 16-bit, adding 0.5 to round
516 0 ▶ print $fh pack('n*', map {$_ < 0 ? 0 : ($_ > 1 ? 65535 : $_ * 65535 + 0.5)} @{$self->[1][$i]->array()});
Branch: 2 branches
BranchTrueFalseTotal
$_ < 0 ? : 0 0 0
$_ > 1 ? : 0 0 0
517
518 }
519
520 }
521
522 # if formula
523 } else {
524
525 # if gamma type 'curv' objects
526 0 ▶ if (UNIVERSAL::isa($self->[1][0], 'ICC::Profile::curv')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($self->[1][0], 'ICC::Profile::curv')) { } 0 0 0
527
528 # for each RGB
529 0 for my $i (0 .. 2) {
530
531 # get 'curv' object index (could be just one 'curv')
532 0 ▶ my $j = defined($self->[1][$i]) ? $i : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[1][$i] ? : 0 0 0
533
534 # get gamma (use 1.0 if undefined)
535 0 ▶ $gamma = defined($self->[1][$j]->array->[0]) ? $self->[1][$j]->array->[0] : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[1][$j]->array->[0] ? : 0 0 0
536
537 # write gamma, min, max (s15Fixed16Number values)
538 0 print $fh pack('N3', ICC::Shared::v2s15f16($gamma, 0, 1));
539
540 }
541
542 # if numeric array
543 } else {
544
545 # for each RGB
546 0 for my $i (0 .. 2) {
547
548 # write gamma, min, max (s15Fixed16Number values)
549 0 print $fh pack('N3', ICC::Shared::v2s15f16(@{$self->[1][$i]}));
550
551 }
552
553 }
554
555 }
556
557 }
558  
559 2 1;
« blib/lib/ICC/Profile/para.pm ↑ Summary blib/lib/ICC/Profile/pseq.pm »