Grayscale image: Difference between revisions

→‎Tcl: Added implementation
(→‎Tcl: Added implementation)
Line 461:
exit 0;</lang>
 
 
=={{header|Tcl}}==
<!-- L = 0.2126·R + 0.7152·G + 0.0722·B -->
{{libheader|Tk}}
<lang tcl>
proc grayscale image {
set w [image width $image]
set h [image height $image]
for {set x 0} {$x<$w} {incr x} {
for {set y 0} {$y<$h} {incr y} {
lassign [$image get $x $y] r g b
set l [expr {int(0.2126*$r + 0.7152*$g + 0.0722*$b)}]
$image put [format "#%02x%02x%02x" $l $l $l] -to $x $y
}
}
}
</lang>
 
=={{header|Vedit macro language}}==
Anonymous user