title: Win2D CanvasBitmap vs Microsoft.UI.Composition CompositionImage
body: <p>EDIT:</p>
  
  <h2>They removed the CompositionImage in the last build ...</h2>
  
  <hr>
  
  <p>I would like to know the difference between Win2D <code>CanvasBitmap</code> and Microsoft.UI.Composition <code>CompositionImage</code>.</p>
  
  <p>In both case I was able to display images but I don't really know/understand the difference between the two approach.</p>
  
  <hr>
  
  <p>The <code>CanvasBitmap</code> approach:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;xaml:CanvasControl Draw="OnDraw"  /&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>private void Onraw(CanvasControl sender, CanvasAnimatedDrawEventArgs e)
          {
             var image = await CanvasBitmap.LoadAsync(...);
             e.DrawingSession.DrawImage(...);
          }
  </code></pre>
  
  <hr>
  
  <p>The <code>CompositionImage</code> approach:</p>
  
  <p>XAML:</p>
  
  <pre><code> &lt;Grid x:Name="Host" /&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>ContainerVisual rootVisual =  
          (ContainerVisual)ElementCompositionPreview.GetContainerVisual(this.Host);
  Compositor compositor = rootVisual.Compositor;
  CompositionGraphicsDevice device = compositor.DefaultGraphicsDevice,
  
  CompositionImage image = device.CreateImageFromUri(...);
  
  ImageVisual content = Compositor.CreateImageVisual();
  content.Image = image;
  
  rootVisual.Children.InsertAtTop(content);
  </code></pre>
  
  <hr>
  
  <p>What's the difference? What is the best approach?</p>
  
  <p>To put thing in the context, I have an application that displays a lot of small images. I need the app to be low on memory and to draw fast the images.</p>
  
  <p>Thanks,
  Adrien.</p>