Tutorial by Examples

<Image x:Name="MyImage" /> // Show image from web MyImage.Source = new BitmapImage(new Uri("http://your-image-url.com")) // Show image from solution MyImage.Source = new Uri("ms-appx:///your-image-in-solution", UriKind.Absolute) // Show image from file ...
<TextBlock x:Name="MyControl" Text="Hello, world!" /> var rtb = new RenderTargetBitmap(); await rtb.RenderAsync(MyControl); // Render control to RenderTargetBitmap // Get pixels from RTB IBuffer pixelBuffer = await rtb.GetPixelsAsync(); byte[] pixels = ...
IRandomAccessStreamReference bitmap = GetBitmap(); IRandomAccessStreamWithContentType stream = await bitmap.OpenReadAsync(); BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream); var pixels = await decoder.GetPixelDataAsync(); var outStream = new InMemoryRandomAccessStream(); // Cr...
<Image Source="ms-appx:///Assets/Windows_10_Hero.png"/> Your image is part of the application, in the Assets folder and marked as Content <Image Source="ms-appdata:///local/Windows_10_Hero.png"/> Your image was saved in your application's Local Folder <Imag...
ImageSource result = new BitmapImage(new Uri("ms-appx:///Assets/Windows_10_Hero.png")); Use result to set the Source property of an Image control either though a Binding or code-behind
public static async Task<ImageSource> FromStorageFile(StorageFile sf) { using (var randomAccessStream = await sf.OpenAsync(FileAccessMode.Read)) { var result = new BitmapImage(); await result.SetSourceAsync(randomAccessStream); return result; } } ...
public static async Task<WriteableBitmap> RenderUIElement(UIElement element) { var bitmap = new RenderTargetBitmap(); await bitmap.RenderAsync(element); var pixelBuffer = await bitmap.GetPixelsAsync(); var pixels = pixelBuffer.ToArray(); var writeableBitmap = new W...
public static async Task<IRandomAccessStream> ConvertWriteableBitmapToRandomAccessStream(WriteableBitmap writeableBitmap) { var stream = new InMemoryRandomAccessStream(); BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream); Stream pixe...

Page 1 of 1