Nevron Open Vision Documentation
Framework / Graphics / Images / Raster Image Animation
In This Topic
    Raster Image Animation
    In This Topic

    Some encoded image sources may contain more than one image – for example GIF files with multiple frames. Such images can be displayed either by rendering a particular frame or by playing back the whole sequence of frames as an animation. To indicate your preferences you can use the AnimateFrames and FrameIndex properties. These properties are not regarded for images that contain only one frame or do not support animation. To start animating a multi-frame raster image simply set it's AnimateFrames property to true. To stop animating the image set the same property to false.

    The following example demonstrates how to load an animated GIF and start animating it:

    Start raster image animation
    Copy Code
    NImage image = NImage.FromFileEmbedded(@"C:\MyImage.gif");
    NEncodedImageSource imageSource = (NEncodedImageSource)image.ImageSource;
    imageSource.AnimateFrames = true;
    

    Some animated GIF images define a number of times their animation should be looped (loop count). NOV honors this preference of each GIF file, but you can easily override it through the LoopCount property of the NEncodedImageSource class. Set its value to the number of times you want the animation to repeat. If set to 0, the animation will play continuously and never stop.

    The following piece of code demonstrates how to start animating a GIF image and play its animation 10 times regardless of the preference stored in the GIF file:

    Start raster image animation
    Copy Code
    NImage image = NImage.FromFileEmbedded(@"C:\MyImage.gif");
    NEncodedImageSource imageSource = (NEncodedImageSource)image.ImageSource;
    imageSource.LoopCount = 10;
    imageSource.AnimateFrames = true;
    
    See Also