Possible to fade a small Tkinter image into a specific background color?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible to fade a small Tkinter image into a specific background color?

python@bdurham.com
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.
 
Thank you,
Malcolm

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

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

Wayne Werner
On Mon, Dec 6, 2010 at 8:38 PM, <[hidden email]> 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


_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

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

Edward Cannon
using the blend function with a solid color image (bg color) and your
image will work, a simple loop changing the alpha value is all you
need. In my experience this is pretty fast. Check the documentation
for details.
Edward Cannon
Unicorn School

On Tue, Dec 7, 2010 at 5:07 AM, Wayne Werner <[hidden email]> wrote:

>
> On Mon, Dec 6, 2010 at 8:38 PM, <[hidden email]> 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
>
> _______________________________________________
> Image-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

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

Chris Barker
In reply to this post by Wayne Werner
On 12/7/10 5:07 AM, Wayne Werner wrote:
> On Mon, Dec 6, 2010 at 8:38 PM, <[hidden email]
>     Wondering if there's a PIL/Tkinter technique I can use to fade a
>     small image into a specific background color?

> 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.

Once you've got it in a numpy array, you can use numpy to manipulate it
-- you're unlikely to need C.

-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig