Skip to content

Instantly share code, notes, and snippets.

@terriblememory
Created June 21, 2018 17:02
Show Gist options
  • Save terriblememory/ead98dceaf4c8fe53a50fbefc036f770 to your computer and use it in GitHub Desktop.
Save terriblememory/ead98dceaf4c8fe53a50fbefc036f770 to your computer and use it in GitHub Desktop.
UWP - populate XAML Image with RGBA image data
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