Solved

Image transistion

Posted on 2007-11-29
3
191 Views
Last Modified: 2013-12-26
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

0
Comment
Question by:DJ_AM_Juicebox
  • 2
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
Comment Utility
you should use a Win32 timer. passing the object pointer. This will fire the timer event ever 'n' miliseconds, so you can repaint in every event.
Of course this will involve other task like kill timer when fade is done and check if window where you show the bitmap is still valid.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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/
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
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")
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now