ARTICLE

Annimation Effect on Image in VB.NET using GDI+

Posted by Sapna Articles | Visual Basic Language December 06, 2010
This article demonstrate you to implement different types of animations or transitions on images with the help of VB.NET using GDI+.
Download Files:
 
Reader Level:

In this article you will learn how to implement different animation effects or you can say transitions on images with the help of VB.NET using GDI+. You can make your slide shows, business presentations, videos, and screensavers more attractive and beautiful using transitions on the web pages/Windows Forms/videos with simple and very easy code.

Annimation Effect on Image in VB.NET using GDI+

animation.gif


Here we apply a simple light-weight timer implemented by the System.Threading.Timer that uses callback functions. Then we declare timer and hook up the Elapsed event for the timer and enable the timer.

Private Sub TimerTick(ByVal source As Object, ByVal e As System.Timers.ElapsedEventArgs)
   Dim ts As TimeSpan = DateTime.Now - m_AnimationStartTime
   m_AnimationPercent = CSng((100.0F / m_AnimationSpeed.TotalSeconds * ts.TotalSeconds))
   If m_AnimationPercent > 100 Then
     m_AnimationPercent = 100
   End If
   Invalidate()
End Sub

The following code example illustrates how to give effects to image
slides from bottom left to top right:

Protected Sub DrawAnimatedImage(ByVal g As Graphics, ByVal control As AnimationControl)
   If m_AnimatedBitmap IsNot Nothing Then
  
 Select Case m_AnimationType
      Case AnimationTypes.BottomLeftToTopRight ' Image effect
      Dim mx As New Drawing2D.Matrix(1, 0, 0, 1, (control.Width * m_AnimationPercent / 100) - control.Width, -(control.Height * m_AnimationPercent / 100) + control.Height)
      g.Transform = mx
      g.DrawImage(m_AnimatedBitmap, control.ClientRectangle, 0, 0, m_AnimatedBitmap.Width, m_AnimatedBitmap.Height, GraphicsUnit.Pixel)
      mx.Dispose()
      Exit Select
    End
Select
  End If
  If m_AnimationPercent = 100 Then
    AnimationStop()
  End If
End Sub

Now when you click on Slide button the image will come as a slide like this:

animation1.gif

Split Boom Animation

animation2.gif

I hope you will enjoy this.

Login to add your contents and source code to this article
share this article :
post comment
 

i m making a image editor in vb.net 2008... i m new in this field, i want to add a red eye effect into the form.... will you plzzz help me............ regards sheena

Posted by Sheenam Dogra Feb 28, 2011
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor