The RasterPictureBox namespace provides a simple "PictureBox" Windows.Forms control with which to display images. Unlike the RasterImageViewer, it does not support scrolling or zooming. However, it does support animation using the Leadtools.RasterImageAnimator class.
Using a RasterPictureBox object is similar to using a RasterImage object. Follow the same steps as those listed in the following section, except instead of using a RasterImage constructor use a RasterPictureBox constructor.
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:
In a loop that processes each frame in the multi-frame image, do the following:
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 the RasterImageAnimatorState enumeration.
The RasterImage.AnimationDisposalMethod property in the target RasterImage object determines what happens to the image in the playback loop after rendering and after any wait state, when the following 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 runs continuously through the list of frames. To stop at the end of the list, exit the loop when the following state is RasterImageAnimatorState.End.
Before you load an animated GIF file, you can use the RasterCodecs.GetInformation method to get the file's global animation information, which is updated in the CodecsImageInfo.Gif property. You can use these values in the animation playback
When you load an animated GIF file, using RasterCodecs.Load, the following animation fields in each RasterImage are updated with information from the file: RasterImage.AnimationOffset, RasterImage.AnimationDelay, RasterImage.AnimationBackground, RasterImage.Transparent, RasterImage.TransparentColor and RasterImage.AnimationDisposalMethod. These properties could be unique for each frame in the image. Also, the global animation information are loaded into the following properties: RasterImage.AnimationGlobalLoop, RasterImage.AnimationGlobalSize and RasterImage.AnimationGlobalBackground. These properties are used in the animation playback
When you save an animated GIF file using the RasterCodecs.Save method, these same RasterImage properties are saved in the file. In addition, the global animation information will be used from the RasterImage automatically. Only the global palette needs to be set manually using the CodecsGifSaveOptions.SetAnimationPalette method and the CodecsGifSaveOptions.UseAnimationPalette property.
Example Location | Description |
---|---|
RasterImageAnimator Example | The following example shows how to load an animated GIF file and paint it on the surface of the given panel control. |
RasterImage.AnimationGlobalLoop Example | The following example shows how to create an animated GIF file |
RasterImage.GetTrueColorValue Example | An example to show how to create transparent GIF file |
See also Introduction Animation
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document