| March 2002 | Perl Hardware Store | 23 |
Another example: Converting RGB values to CMYK values:
sub cmyk {
my ($r, $g, $b) = @_;
my ($c, $m, $y) = (1-$r, 1-$g, 1-$b);
my $k = $c < $m ? ($c < $y ? $c : $y)
: ($m < $y ? $m : $y); # Minimum
for ($c, $m, $y) { $_ -= $k }
[$c, $m, $y, $k];
}
Many image formats (including GIF) have many pixels that are the same color.
This recomputes the same CMYK values over and over.
| Next | ![]() |
Copyright © 2002 M-J. Dominus |