Solved

Image transistion

Posted on 2007-11-29
3
192 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
ID: 20379285
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
ID: 20379297
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
ID: 20379667
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Handle Exceptions during instantiation 28 411
Game w 3D galaxy - How should I do vertical distancing? 3 73
VS2015 compilation and missing DLLs 9 114
Best book to learn C++ 4 70
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

919 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

21 Experts available now in Live!

Get 1:1 Help Now