Link to home
Start Free TrialLog in
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

asked on

Image transistion

Hi,

I wanted to make a simple image effect. I want a bitmp to fade to %100 transparency for example. I'm not sure how this would be done in a general sense. I'm working on win32.

I was thinking that I could have an image class with a member that represents opactiy:

    class FadeImage {
        Bitmap m_Img;
        double m_dOpacity = 100.0;
    };

When I want the image to fade, I can just call some method to initiate it, and keep generating WM_PAINT messages until it's done:

     void FadeImage::StartFade()
     {
          while (m_dOpacity != 0) {
               m_dOpacity--;
               Invalidate();
          }
     }

That would work, but the system will just block the user from doing much until the fade is done. I'm wondering how packages like flash do it. They can carry a fade out while still allowing mouse interaction. What's the general way to do something like this?

Thanks

ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A clock application would be a good example about using timer to repaint. Have a look to this one:
http://smallcode.weblogs.us/2006/04/11/things-are-not-as-easy-as-they-seem-writing-a-clock-application/
Avatar of jkr
If you want transparency, probably using 'SetLayeredWindowAttributes()' (http://msdn2.microsoft.com/en-us/library/ms633540.aspx) is more what you are looking for. See also http://www.codeproject.com/w2k/trans.asp ("Transparency without Source Code")