public enum RasterImageAnimatorState
typedef NS_ENUM(NSInteger, LTRasterImageAnimatorState) {
LTRasterImageAnimatorStatePreClear = 0x0000,
LTRasterImageAnimatorStatePostClear = 0x0001,
LTRasterImageAnimatorStatePreRender = 0x0002,
LTRasterImageAnimatorStateRender = 0x0003,
LTRasterImageAnimatorStatePostRender = 0x0004,
LTRasterImageAnimatorStateWaitInput = 0x0005,
LTRasterImageAnimatorStateWaitDelay = 0x0006,
LTRasterImageAnimatorStateWaitInputDelay = 0x0007,
LTRasterImageAnimatorStatePreDispose = 0x0008,
LTRasterImageAnimatorStatePostDispose = 0x0009,
LTRasterImageAnimatorStateEnd = 0x000A
};
public enum class RasterImageAnimatorState
class RasterImageAnimatorState(Enum):
PreClear = 0
PostClear = 1
PreRender = 2
Render = 3
PostRender = 4
WaitInput = 5
WaitDelay = 6
WaitInputDelay = 7
PreDispose = 8
PostDispose = 9
End = 10
Value | Member | Description |
---|---|---|
0 | PreClear | The initial state of the animation (index = -1). The target image will be cleared to the RasterImage.AnimationBackground color of the current frame on the next call |
1 | PostClear | Indicates that the target image has been cleared |
2 | PreRender | Indicates that the current frame will be rendered to the target image on the next call |
3 | Render | Indicates that a frame has been rendered to the target image |
4 | PostRender | Indicates that a frame is in the midst of being rendered to the target image |
5 | WaitInput | Indicates that the animation engine is waiting for user input before moving on to PreDispose |
6 | WaitDelay | Indicates that the animation engine is waiting for a delayed time before moving on to PreDispose |
7 | WaitInputDelay | Indicates that the animation engine is waiting for user input and a delayed time before moving on to PreDispose |
8 | PreDispose | Indicates that the current frame will be disposed of on the next call |
9 | PostDispose | Indicates that the current frame has been disposed of. The index is incremented after processing this state |
10 | End | Indicates that the animation is past the last frame in the list (index = number of frames or pages). The animator will loop to index = 0 on the next call with the state set to PreRender |
This enumeration is used as the state of the RasterImageAnimator. It is used as the value of the RasterImageAnimator.State property and the return value of the RasterImageAnimator.Process method.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.Drawing;
public void RasterImageAnimatorExample(Panel panel)
{
// Initialize the RasterCodecs object
RasterCodecs codecs = new RasterCodecs();
// When loading the animated GIF file, we have two means to load all pages into memory
// Option 1: Set the Load All Pages to true, then specify just the filename
string fileName = Path.Combine(LEAD_VARS.ImagesDir, "Eye.gif");
codecs.Options.Load.AllPages = true;
RasterImage animatedImage = codecs.Load(fileName);
// Option 2: Specify which pages to load, -1 means all pages
// Load the animated GIF file
//RasterImage animatedImage = codecs.Load(filename, 0, CodecsLoadByteOrder.Bgr, 1, -1)
// 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;
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.PostClear:
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