Solved

Image transistion

Posted on 2007-11-29
3
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
scoresClump  challenge 31 156
Exception thrown at 0x00007FFD5BC81F28 7 62
What are programming codes and how do they work? 7 119
using interface in TLB 3 32
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

710 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