B2Ben
Well-known member
- Joined
- Aug 17, 2006
- Messages
- 52
- Programming Experience
- Beginner
I'm building an application that will allow me to play video and display images full-screen. I'm trying to build a routine that will allow me to fade into an image.
My main form is a black-background, maximized form - thus making the entire screen black. When I want to see an image, I set the backgroundimage property to my image.
When I want to fade into something, I create a temporary maximized form on top, set the background image, and then slowly adjust the opacity from 0 to 1. So far it works great.
When the fade-in effect is done, I want to display the new image on my main form, and get rid of my temporary form I used for the animation.
The problem... When I update the main form's image, and hide the "fade-in" form, it triggers a nasty screen refresh, causing the image to flash for a split second, ruining the nice effect. It looks like: Black... Fading in... Fading in... Fading in... Screen goes black for a split second while refreshing... Done. My new image is now showing completely opaque.
I feel like I'm so close, but that ugly refresh just wrecks the whole effect.
If anyone has any ideas, it would be greatly appreciated.
Here's a little bit of code...
My main form is a black-background, maximized form - thus making the entire screen black. When I want to see an image, I set the backgroundimage property to my image.
When I want to fade into something, I create a temporary maximized form on top, set the background image, and then slowly adjust the opacity from 0 to 1. So far it works great.
When the fade-in effect is done, I want to display the new image on my main form, and get rid of my temporary form I used for the animation.
The problem... When I update the main form's image, and hide the "fade-in" form, it triggers a nasty screen refresh, causing the image to flash for a split second, ruining the nice effect. It looks like: Black... Fading in... Fading in... Fading in... Screen goes black for a split second while refreshing... Done. My new image is now showing completely opaque.
I feel like I'm so close, but that ugly refresh just wrecks the whole effect.
If anyone has any ideas, it would be greatly appreciated.
Here's a little bit of code...
VB.NET:
Private Panel as new FadeForm
Private Sub DoFade()
Panel.BackgroundImage = Me.SetFadeImage
Panel.BackColor = Me.SetFadeColor
Panel.Opacity = 0
Panel.Show()
Panel.BringToFront()
Panel.Refresh()
For Opac As Double = 0 To 1 Step 0.01
Panel.Opacity = Opac
System.Threading.Thread.Sleep(10)
Application.DoEvents()
Next
'Fade complete. Update main screen with new image/color and hide the fade panel.
Me.BackColor = Panel.BackColor
Me.BackgroundImage = Panel.BackgroundImage
Panel.Hide()
End Sub