Created
June 21, 2018 17:02
-
-
Save terriblememory/ead98dceaf4c8fe53a50fbefc036f770 to your computer and use it in GitHub Desktop.
UWP - populate XAML Image with RGBA image data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bgraBuffer = new byte[256 * 256 * 4]; | |
// whatever you need to do to populate the image buffer | |
var sbm = SoftwareBitmap.CreateCopyFromBuffer(bgraBuffer.AsBuffer(), BitmapPixelFormat.Bgra8, 256, 256, BitmapAlphaMode.Premultiplied); | |
var sbms = new SoftwareBitmapSource(); | |
var ignore_this_task_it_doesnt_matter = sbms.SetBitmapAsync(sbm); | |
// SetBitmapAsync may still be in flight but it doesn't matter | |
var image = Image(); | |
image.Source = sbms; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment