Visual Basic (Declaration) | |
---|---|
Public Class RasterImageAnimator |
Visual Basic (Usage) | Copy Code |
---|---|
|
C# | |
---|---|
public class RasterImageAnimator |
C++/CLI | |
---|---|
public ref class RasterImageAnimator |
This example will load an animated GIF file and paint on the surface of the given Panel.
Visual Basic | Copy Code |
---|---|
Sub RasterImageAnimatorExample(ByVal panel As Panel) |
C# | Copy Code |
---|---|
void RasterImageAnimatorExample(Panel panel) |
To load and play an animated file, such as GIF, you can load the frames into a RasterImage object from the file, then play the list to a target image in a loop that displays each change in the target image. You can also create an animation sequence from scratch and save the images to create an animated GIF file.
The following is an outline of possible steps:
Load a multi-frame image using Load Use the RasterImage constructor to create a target image that is the size of the images in the multi-frame image Use the RasterImageAnimator class to create an animation playback that references multi-frame image and the target image In a loop that processes each frame in the multi-frame image, do the following: Use RasterImageAnimator.Process to process the current state and get the next state of the animation Use RasterImageAnimator.GetUpdateRectangle to get the update rectangle (the portion of the target image that has changed) Use RasterImage.Paint to paint the changed portion of the image. To paint only the changed portion, use the update rectangle as the source clipping rectangle.
The animation loop can have a number of states, and you should only paint the changes in an appropriate state (for example, when the next state is RasterImageAnimatorState.PostRender. For a list of possible states, refer to RasterImageAnimatorState.
The RasterImage.AnimationDisposalMethod property in the target RasterImage determines what happens to the image in the playback loop after rendering and after any wait state, when the next state is RasterImageAnimatorState.PostDispose. The options are as follows: keep the image as it is, restore the background, or restore the previous image. (Restoring the background is a common option for animation.)
The animation loop goes continuously through the list of frames. If you want to stop at the end of the list, you can exit the loop when the next state is RasterImageAnimatorState.End.
The RasterImageAnimator class also implements the IDisposable interface, it is recommended that you follow the standard .NET dispose pattern when using the RasterImageAnimator class. For more information, refer to IDisposable.
System.Object
Leadtools.RasterImageAnimator
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family