Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Image transistion

Posted on 2007-11-29
3
Medium Priority
?
198 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

722 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