Hololens/Lib/ImageConversion.cs
//########################################################################################
/// <summary>
/// Convert the bitmap object to a displayable format to use in XAML.
/// </summary>
/// <param name="bitmap"> SoftwareBitmap object </param>
/// <returns> a SoftwareBitmap object converted to Bgra8 and premultiplied format </returns>
Convert the bitmap object to a displayable format to use in XAML.
Convert the bitmap object to a displayable format to use in XAML .
public static SoftwareBitmap ToDisplayableXaml(SoftwareBitmap bitmap)
        {
            if (bitmap != null)
            {
                if (bitmap.BitmapPixelFormat != BitmapPixelFormat.Bgra8 || bitmap.BitmapAlphaMode != BitmapAlphaMode.Premultiplied)
                {
                    return SoftwareBitmap.Convert(bitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied);
                }
                else
                {
                    return bitmap;
                }
            }
            else
            {
                return null;
            }
        }
public static SoftwareBitmap ToDisplayableXaml ( SoftwareBitmap bitmap ) { if ( bitmap != null ) { if ( bitmap . BitmapPixelFormat != BitmapPixelFormat . Bgra8 || bitmap . BitmapAlphaMode != BitmapAlphaMode . Premultiplied ) { return SoftwareBitmap . Convert ( bitmap , BitmapPixelFormat . Bgra8 , BitmapAlphaMode . Premultiplied ) ; } else { return bitmap ; } } else { return null ; } }
Convert the bitmap object to a displayable format to use in XAML.
Convert the bitmap object to a displayable format to use in XAML .
a SoftwareBitmap object converted to Bgra8 and premultiplied format
a SoftwareBitmap object converted to Bgra8 and premultiplied format
bitmap
SoftwareBitmap
None