[Image-SIG] [Tkinter-discuss] Possible to fade a small Tkinter image into a specific background color?

Wayne Werner waynejwerner at gmail.com
Tue Dec 7 14:07:30 CET 2010


On Mon, Dec 6, 2010 at 8:38 PM, <python at bdurham.com> wrote:

> Wondering if there's a PIL/Tkinter technique I can use to fade a small
> image into a specific background color?
>
> Use case: I have a small message area that displays both an icon and text
> message. I can fade my foreground text into its background container by
> iteratively moving my message text's rgb components towards its background
> rgb value until my text has the same foreground and background colors.
>
> I'm wondering if there's a similar technique I can use with PIL and its
> Image, ImageTk classes to do the same with an image displayed in Tkinter? I
> suspect I can do this by inspecting and updating every pixel individually,
> but this seems very inefficent.
>

Well, if you convert the image to a numpy array then you can call some C
functions on it so it's not that slow. I'm not sure if any of the other PIL
structures are natively C. Any type of fade operation you could call would
be doing something on a per-pixel basis (even if the operations themselves
are being performed in a very low-level language) anyway. This would just
require you to implement it yourself.

That's about the extent of my knowledge, there may be others with better
ideas (or who can contradict mine!).

HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20101207/f5111ea5/attachment.html>


More information about the Image-SIG mailing list