EDIT:
They removed CompositionImage in the latest build ...
I would like to know the difference between Win2D CanvasBitmapand Microsoft.UI.Composition CompositionImage.
In both cases, I was able to display images, but I really don't know / don't understand the difference between the two approaches.
Approach CanvasBitmap:
XAML:
<xaml:CanvasControl Draw="OnDraw" />
code:
private void Onraw(CanvasControl sender, CanvasAnimatedDrawEventArgs e)
{
var image = await CanvasBitmap.LoadAsync(...);
e.DrawingSession.DrawImage(...);
}
Approach CompositionImage:
XAML:
<Grid x:Name="Host" />
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);
Who cares? What is the best approach?
To put an object in context, I have an application that displays a lot of small images. I need the application to be low in memory and quickly draw images.
Thanks Adrien.
source
share