C#
VB
WinRT C#
C++
Clears the update rectangle used for an animation playback, leaving an empty rectangle.
public void ClearUpdateRectangle() Public Sub ClearUpdateRectangle() public void ClearUpdateRectangle() function Leadtools.RasterImageAnimator.ClearUpdateRectangle() public:void ClearUpdateRectangle();
This example uses ClearUpdateRectangle to avoid painting odd numbered frames
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.Drawing;using LeadtoolsExamples.Common;[Ignore()]public void RasterImageAnimatorClearUpdateRectangleExample(Panel panel){// Initialize the RasterCodecs objectRasterCodecs codecs = new RasterCodecs();// Load the animated GIF filestring fileName = Path.Combine(ImagesPath.Path, "Eye.gif");RasterImage animatedImage = codecs.Load(fileName);// Create the target image, we want it to be in the animated image sizeRasterImage 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 imageanimatedImage.CopyPaletteTo(targetImage);// Create the RasterImageAnimator objectRasterImageAnimator animator = new RasterImageAnimator(targetImage, animatedImage);// Animate it// Use GDI+ paint engine to support transparent colorsRasterPaintProperties 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 processingbreak;case RasterImageAnimatorState.WaitInput:// In case the animated image has the "wait for user input" flags,// cancel the waitinganimator.CancelWait();break;case RasterImageAnimatorState.PostRender:index = animator.Index;if ((index % 2) != 0)animator.ClearUpdateRectangle();// Get the area in the target image that has changedupdateRect = animator.GetUpdateRectangle(true);// Paint itdestRect = 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();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.DrawingSub RasterImageAnimatorClearUpdateRectangleExample(ByVal panel As Panel)' Initialize the RasterCodecs objectDim codecs As New RasterCodecs()' Load the animated GIF fileDim fileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Eye.gif")Dim animatedImage As RasterImage = codecs.Load(fileName)' Create the target image, we want it to be in the animated image sizeDim targetImage As New RasterImage(RasterMemoryFlags.Conventional,animatedImage.AnimationGlobalSize.Width,animatedImage.AnimationGlobalSize.Height,animatedImage.BitsPerPixel,animatedImage.Order,animatedImage.ViewPerspective,Nothing,IntPtr.Zero,0)' Copy the palette from the animated image to this newly created imageanimatedImage.CopyPaletteTo(targetImage)' Create the RasterImageAnimator objectDim animator As New RasterImageAnimator(targetImage, animatedImage)' Animate it' Use GDI+ paint engine to support transparent colorsDim props As RasterPaintProperties = RasterPaintProperties.Defaultprops.PaintEngine = RasterPaintEngine.GdiPlusDim g As Graphics = panel.CreateGraphics()Dim state As RasterImageAnimatorStateDoDim srcRect As New LeadRect(0, 0, targetImage.ImageWidth, targetImage.ImageHeight)Dim updateRect As LeadRectDim destRect As LeadRectDim index As Integerstate = animator.Process()Select Case (state)Case RasterImageAnimatorState.WaitDelay,RasterImageAnimatorState.WaitInputDelay,RasterImageAnimatorState.Render' Continue processingCase RasterImageAnimatorState.WaitInput' In case the animated image has the "wait for user input" flags,' cancel the waitinganimator.CancelWait()Case RasterImageAnimatorState.PostRenderindex = animator.IndexIf ((index Mod 2) <> 0) Thenanimator.ClearUpdateRectangle()End If' Get the area in the target image that has changedupdateRect = animator.GetUpdateRectangle(True)' Paint itdestRect = New LeadRect(0, 0, targetImage.ImageWidth, targetImage.ImageHeight)RasterImagePainter.Paint(targetImage, g, srcRect, updateRect, destRect, destRect, props)End SelectLoop While (state <> RasterImageAnimatorState.End)g.Dispose()animator.Dispose()targetImage.Dispose()animatedImage.Dispose()codecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
