Sujet : Re: Image background
De : obermeier (at) *nospam* poSoft.de (Paul Obermeier)
Groupes : comp.lang.tclDate : 17. Oct 2024, 20:49:27
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <verpp4$2sn6r$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
Am 17.10.2024 um 21:04 schrieb saito:
I wonder if it is possible to remove the background from an image and make it transparent using Tk or a package? Then I can save it as a png image. The background in my case consists of a single color. Perhaps I could replace that color with an "alpha" color but how?
proc SetTransparentColor { phImg { red 255 } { green 255 } { blue 255 } } {
set colorStr [format "#%02x%02x%02x" $red $green $blue]
set y 0
foreach row [$phImg data] {
set x 0
foreach pixel $row {
if { $colorStr eq $pixel } {
$phImg transparency set $x $y 1
}
incr x
}
incr y
}
}
Paul