Fade transition of a picture

G

Guest

Hi,

if you open the link below and click on "Show Me" and then "Toggle
Transition" Button you will see a wonderfull fade in / fade out transition of
2 pictures.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/filter/reference/filters/fade.asp

I want to have the same effect in Visual C++, dosen't matter with / or
without GDI+, but no .NET. I have a simple dialog with some controls and I
want to fade in / fade out some pictures on the dialog, some with fade
transition. I tried a lot: MemDC/double buffering, GDI+, what ever, but
allways I get a flicker on the screen.
Does anybody knows some good stuf to obtain the result like in the link
above in a Visual C++ app ?
For any idea thanks in advance!

Best Regards,
Emil
 
B

Bruno van Dooren

a demo app that i made 2 years ago using C# did something like this by using
a forms property.

you can change the opacity of window forms. if you overlay one on top of the
other, you can use the opacity
of the foreground window to fade the picture in and out of view if you put
the picture behind it.

this would also work with windows forms in C++ .NET, and without too much
hassle.
this is probably also possible using plain GDI, but i have never used that.

but there might be better ways to do this.

kind regards,
Bruno.



there might be
 
C

Carl Daniel [VC++ MVP]

Emil said:
Hi,

if you open the link below and click on "Show Me" and then "Toggle
Transition" Button you will see a wonderfull fade in / fade out
transition of 2 pictures.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/filter/reference/filters/fade.asp

I want to have the same effect in Visual C++, dosen't matter with / or
without GDI+, but no .NET. I have a simple dialog with some controls
and I
want to fade in / fade out some pictures on the dialog, some with fade
transition. I tried a lot: MemDC/double buffering, GDI+, what ever,
but
allways I get a flicker on the screen.
Does anybody knows some good stuf to obtain the result like in the
link
above in a Visual C++ app ?
For any idea thanks in advance!

A fade transition is typically done by overlaying one window on top of
another and adjusting the transparency of the top window.

The transition algorithm would be something like:

0. Assume that Window 1 contains picture A and you're going to transition to
picture B
1. Create Window 2 that exactly overlays window 1 and is 100% transperent
(see SetLayedWindowAttributes)
2. Copy Picture B to window 2 (e.g. SetDIBitsToDevice)
3. using a windows timer, animate the transparency of Window 2 from fully
transparent to fully opaque.
4. once window 2 is fully opaque, copy picture B to window 1 and then
destroy window 2

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top