Code Examples
  Home arrow Code Examples arrow Page 2 - Handling Animations and Bitmaps Using GDI+...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Handling Animations and Bitmaps Using GDI+ for Image Manipulation
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 14
    2007-03-20

    Table of Contents:
  • Handling Animations and Bitmaps Using GDI+ for Image Manipulation
  • Playing with Animation: StopAnimate and UpdateFrame
  • Working With Bitmaps
  • Image Animation in the Real World

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Handling Animations and Bitmaps Using GDI+ for Image Manipulation - Playing with Animation: StopAnimate and UpdateFrame


    (Page 2 of 4 )

    Just as the name suggests, the StopAnimate method stops the animation; in effect, it's the reverse of StartAnimate(). The parameters accepted by this method are the same as those for StartAnimate, namely the image to animate and the handler to be called when the frame changes. The following code illustrates the point:

    if(curImage != null)
    {
      ImageAnimator.StopAnimate(curImage,
      new EventHandler(this.OnFrameChanged));
    }

    where curImage is the reference of the image to be animated and OnFrameChanged is the handler to be called which is define as

    private void OnFrameChanged(object o, EventArgs e) {
      //Force a call to the Paint event handler.
      this.Invalidate();
    }

    UpdateFrames is used to prepare the next frame for rendering. There are two versions of the method. One accepts an image reference as a parameter, while the other version doesn't accept any parameter. If the former is used, only the frame in the reference image is advanced i.e. prepared for rendering. When the latter is used, it advances the frame in all images currently being animated i.e. if there is more than one image being animated, frames in all the images are prepared for rendering. The actual rendering is done when the next Paint event occurs. The following code explains the point:

    protected override void OnPaint(PaintEventArgs e) {
      //Begin the animation.
      //call the method to start animation
      //Get the next frame ready for rendering.
      ImageAnimator.UpdateFrames();
      //Draw the next frame in the animation.
      e.Graphics.DrawImage(this.animatedImage, new Point(0, 0));
    }


    Once the Animate method is called, the UpdateFrames method is called to prepare the next frame for animation.

    That brings us to the end of this section. In the next section the focus will be on the basics of bitmap manipulation.

    More Code Examples Articles
    More By A.P.Rajshekhar


       · In this artocle I have discussed about handling animated gif and basics of bitmap...
     

    CODE EXAMPLES ARTICLES

    - Handling Animations and Bitmaps Using GDI+ f...
    - Download a Web Page using the WebClient
    - Creating a Chart using Data from a Database ...
    - The Basics of Charting with the MS Chart Con...
    - Searching Body Text with textRange: Enter th...
    - Searching Body Text with textRange: Building...
    - Searching Body Text with textRange, part 1: ...
    - First Steps in Programming
    - Programming in C
    - Quick Introduction to ASF,ASX, and Networkin...
    - SatView: Pointer Perfect, Part 2: Constructi...
    - SatView: Pointer Perfect, Part 1
    - Style Case Studies: Construction Unions
    - Creating an Engine for Games for Windows
    - Style Case Studies: Generic Callbacks





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT