public int Index { get; set; }
@property (nonatomic, assign) NSInteger index;
Index # get and set (RasterImageAnimator)
An integer value that indicates the index of the current frame during animation playback.
You can use the Index property to skip frames during a playback if required.
This example uses Index to skip frames during a playback
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.Drawing;
public void RasterImageAnimatorIndexExample(Panel panel)
{
// Initialize the RasterCodecs object
RasterCodecs codecs = new RasterCodecs();
// Load the animated GIF file
string fileName = Path.Combine(LEAD_VARS.ImagesDir, "Eye.gif");
RasterImage animatedImage = codecs.Load(fileName);
// Create the target image, we want it to be in the animated image size
RasterImage targetImage = new RasterImage(
RasterMemoryFlags.Conventional,
animatedImage.AnimationGlobalSize.Width,
animatedImage.AnimationGlobalSize.Height,
animatedImage.BitsPerPixel,
animatedImage.Order,
animatedImage.ViewPerspective,
null,
IntPtr.Zero,
0);
// Copy the palette from the animated image to this newly created image
animatedImage.CopyPaletteTo(targetImage);
// Create the RasterImageAnimator object
RasterImageAnimator animator = new RasterImageAnimator(targetImage, animatedImage);
// Animate it
// Use GDI+ paint engine to support transparent colors
RasterPaintProperties props = RasterPaintProperties.Default;
props.PaintEngine = RasterPaintEngine.GdiPlus;
Graphics g = panel.CreateGraphics();
RasterImageAnimatorState state;
do
{
LeadRect srcRect = new LeadRect(0, 0, targetImage.ImageWidth, targetImage.ImageHeight);
LeadRect updateRect;
LeadRect destRect;
int index;
state = animator.Process();
switch (state)
{
case RasterImageAnimatorState.WaitDelay:
case RasterImageAnimatorState.WaitInputDelay:
case RasterImageAnimatorState.Render:
// Continue processing
break;
case RasterImageAnimatorState.WaitInput:
// In case the animated image has the "wait for user input" flags,
// cancel the waiting
animator.CancelWait();
break;
case RasterImageAnimatorState.PreRender:
index = animator.Index;
index++;
animator.Index = index;
break;
case RasterImageAnimatorState.PostRender:
// Get the area in the target image that has changed
updateRect = animator.GetUpdateRectangle(true);
// Paint it
destRect = new LeadRect(0, 0, targetImage.ImageWidth, targetImage.ImageHeight);
RasterImagePainter.Paint(targetImage, g, srcRect, updateRect, destRect, destRect, props);
break;
default:
break;
}
}
while (state != RasterImageAnimatorState.End);
g.Dispose();
animator.Dispose();
targetImage.Dispose();
animatedImage.Dispose();
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
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