Skip to content

Instantly share code, notes, and snippets.

@dupuyjs
Created March 4, 2016 17:46
Show Gist options
  • Save dupuyjs/2e2b86fc15e34f20ac74 to your computer and use it in GitHub Desktop.
Save dupuyjs/2e2b86fc15e34f20ac74 to your computer and use it in GitHub Desktop.
Visual Layer - Image
#region Image Visual
Uri localUri = new Uri("ms-appx:///Assets/windowscube.jpg");
var imageFactory = CompositionImageFactory.CreateCompositionImageFactory(_compositor);
CompositionImageOptions options = new CompositionImageOptions()
{
DecodeWidth = 450,
DecodeHeight = 300,
};
var image = imageFactory.CreateImageFromUri(localUri, options);
var imageBrush = _compositor.CreateSurfaceBrush(image.Surface);
var visual = _compositor.CreateSpriteVisual();
visual.Size = new Vector2(450.0f, 300.0f);
visual.Offset = new Vector3(250.0f, 250.0f, 0.0f);
visual.Brush = imageBrush;
root.Children.InsertAtTop(visual);
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment