C# Transparency issues
-
Hey, So i'm working on this form that fades in and out depending on when it's active or not. Essentially it's a for loop that just iterates the opacity value of the form up to the desired value. for(float f = 0.0f; f < 0.5f; f += 0.05f) { this.Opacity = f; } The problem is, this is really slow and flickery. I'm hoping to get something around the speed of the fading in and out of Winamp 5, if you all have seen that. something along the lines of 100-500ms, or even < 1s, but still have it look smoothe and not flicker so much. Any suggestions? I mean will DirectDraw do what I want? Thanks. -- Adam "If you can't beat your computer in chess, try kickboxing"
-
Hey, So i'm working on this form that fades in and out depending on when it's active or not. Essentially it's a for loop that just iterates the opacity value of the form up to the desired value. for(float f = 0.0f; f < 0.5f; f += 0.05f) { this.Opacity = f; } The problem is, this is really slow and flickery. I'm hoping to get something around the speed of the fading in and out of Winamp 5, if you all have seen that. something along the lines of 100-500ms, or even < 1s, but still have it look smoothe and not flicker so much. Any suggestions? I mean will DirectDraw do what I want? Thanks. -- Adam "If you can't beat your computer in chess, try kickboxing"
Through a
Thread.Sleep
in the loop taking into account the duration of the effect and the number of iterations required.Microsoft MVP, Visual C# My Articles
-
Through a
Thread.Sleep
in the loop taking into account the duration of the effect and the number of iterations required.Microsoft MVP, Visual C# My Articles
Wouldn't that make the fade longer? -- Adam "If you can't beat your computer in chess, try kickboxing"
-
Wouldn't that make the fade longer? -- Adam "If you can't beat your computer in chess, try kickboxing"
Right now your loop doesn't take any time into account and depends upon the speed of your machine. You need to control the opacity. Right now, the loop would probably run so fast that it would appear to jump from 0.0 to 0.5 (or whatever it was) immediately. You need to control the duration. When you're talking about 10 ms or so, the naked eye typically won't catch it. Just think of movies you watch. In the use, it's only 29.97 fps (NTSC) where in other parts of the world it's like 30 fps (PAL) or something. Do you notice each individual frame? if you need 10 iterations and use
Thread.Sleep(50)
to sleep for 50 ms between each iteration, your fade effect will take only 500 ms like you mentioned a desire for in your first post.Microsoft MVP, Visual C# My Articles
-
Wouldn't that make the fade longer? -- Adam "If you can't beat your computer in chess, try kickboxing"
It would, but that would make the fade more 'realistic'. Also call Application.DoEvents() after each call, so the UI seem to 'respond'. top secret xacc-ide 0.0.1
-
Right now your loop doesn't take any time into account and depends upon the speed of your machine. You need to control the opacity. Right now, the loop would probably run so fast that it would appear to jump from 0.0 to 0.5 (or whatever it was) immediately. You need to control the duration. When you're talking about 10 ms or so, the naked eye typically won't catch it. Just think of movies you watch. In the use, it's only 29.97 fps (NTSC) where in other parts of the world it's like 30 fps (PAL) or something. Do you notice each individual frame? if you need 10 iterations and use
Thread.Sleep(50)
to sleep for 50 ms between each iteration, your fade effect will take only 500 ms like you mentioned a desire for in your first post.Microsoft MVP, Visual C# My Articles
Heath Stewart wrote: Just think of movies you watch. In the use, it's only 29.97 fps (NTSC) where in other parts of the world it's like 30 fps (PAL) or something. Movies are usually 24fps, while PAL is 25fps. Animations like Simpsons are tradionally 15fps, but I suspect that was before CG and computer animation came into play. top secret xacc-ide 0.0.1
-
Heath Stewart wrote: Just think of movies you watch. In the use, it's only 29.97 fps (NTSC) where in other parts of the world it's like 30 fps (PAL) or something. Movies are usually 24fps, while PAL is 25fps. Animations like Simpsons are tradionally 15fps, but I suspect that was before CG and computer animation came into play. top secret xacc-ide 0.0.1
Actually, you had one right (PAL, and thanks for correcting me on that) but the 29.97 fps I am sure of. See http://www.microcinema.com/index/ntsc[^], for example.
Microsoft MVP, Visual C# My Articles
-
Actually, you had one right (PAL, and thanks for correcting me on that) but the 29.97 fps I am sure of. See http://www.microcinema.com/index/ntsc[^], for example.
Microsoft MVP, Visual C# My Articles
Heath Stewart wrote: you had one right Sorry, with movies, I meant film as in the theater, thats 24fps, NTSC (never the same color) is 29.97fps :) top secret xacc-ide 0.0.1
-
Hey, So i'm working on this form that fades in and out depending on when it's active or not. Essentially it's a for loop that just iterates the opacity value of the form up to the desired value. for(float f = 0.0f; f < 0.5f; f += 0.05f) { this.Opacity = f; } The problem is, this is really slow and flickery. I'm hoping to get something around the speed of the fading in and out of Winamp 5, if you all have seen that. something along the lines of 100-500ms, or even < 1s, but still have it look smoothe and not flicker so much. Any suggestions? I mean will DirectDraw do what I want? Thanks. -- Adam "If you can't beat your computer in chess, try kickboxing"
You could handle this using a timer in your form. Handle its elapsed event and make gradual changes with each tick, stopping the counter when the opacity reached its min or max. I have done this and it produces no flicker. Happy Programming and God Bless! Internet::WWW::CodeProject::bneacetp