title: Xamarin forms ImageSource for sprite animation?
body: <p>I am wanting to put a little animated logo on my Xamarin Form.  </p>
  
  <p>it basically works but it looks terrible.  IE flickers</p>
  
  <p>it appears that is either the ImageSource.FromFile() is <em>lazy</em> and loads the file from storage every time it is accessed, or setting the Image.Source is not buffered and causes tearing/flickering, or both? </p>
  
  <p>i'm new to xamarin, i've never had this problem working in native java/obj-c before.</p>
  
  <p>Does anyone have any suggestions?  Is there any way to force the ImageSource to actually pre-load into memory?  Is there a way to update the Image.Source property without flicker?  Or should I try to move to an XamarinIOS/Android custom (native) control?</p>
  
  <pre class="lang-cs prettyprint-override"><code> public partial class SplashIntro : ContentPage {
  
      ImageSource[] sprites = new ImageSource[17];
  
      public SplashIntro() {
        InitializeComponent();
        LoadSplashImages();
        this.Appearing += SplashIntro_Appearing;
      }
  
      private void SplashIntro_Appearing(object sender, EventArgs e) {
        PlayAni();
      }
  
      void LoadSplashImages() {
        for (int i = 0; i &lt; sprites.Length; i++) {
          ImageSource ims = ImageSource.FromFile($"logani{i + 1}.png");
          sprites[i] = ims;
        }
      }
  
      void PlayAni() {
        aniImage.Source = sprites[0];
        int nextFrame = 1;
        Device.StartTimer(TimeSpan.FromMilliseconds(80), () =&gt; {
          //  Device.BeginInvokeOnMainThread(() =&gt; { aniImage.Source = sprites[nextFrame]; });
          aniImage.Source = sprites[nextFrame];
          nextFrame++;
          if (nextFrame == sprites.Length) nextFrame = 0;
          return true;
        });
      }
    }
  </code></pre>