| Aric Bills 2007-06-28, 4:18 am |
| Images, unlike widgets, don't have a -state option, and I think
ultimately to change their appearance you have to actually change the
image. However, you do have plenty of options for programmatically
generating the alternate image.
You *should* be able to something along these lines:
set original [image create photo -file image.jpg]
set modified [image create photo -data [$original data -
grayscale]]
(you then have an image $display and you use [$display copy $original]
or [$display copy $modified] as appropriate)
This worked for me in 8.4.14 but not in 8.5a6 (where $modified came
out black).
Another easy option is to overlay a semi-transparent layer onto your
original image to create one that is darker/lighter/yellowish/greenish/
etc. To do this you'll need to create a little .png file that is all
one color and partially transparent. The .png file needn't have the
same dimensions as the image it's being overlaid on--in fact it can be
just a few pixels wide and high. The -to option of the copy
subcommand will duplicate it as necessary.
set original [image create photo -file image.jpg]
set overlay [image create photo -file semitransparent.png]
set modified [image create photo]
$modified copy $original
$modified copy $overlay \
-to 0 0 [image width $original] [image height $original] \
-compositingrule overlay
Other options are certainly possible, especially if you're willing to
use TclMagick or to write image manipulation code yourself, but these
are among the simpler effects you might go after.
|