working on it ...

Filters

Explore Public Snippets

Sort by

Found 1 snippet

    public by guantalamo56  89  0  4  0

    UWP: turn byte array into image

    Given a byte array, let's turn it into an Image that can be used in UWP UI contexts.
    public static async Task<Image> ToImage(this byte[] input)
    {
    	if (input == null)
    		return null;
    	BitmapImage biSource = new BitmapImage();
    	using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream())
    	{
    		await stream.WriteAsync(input.AsBuffer());
    		stream.Seek(0);
    		await biSource.SetSourceAsync(stream);
    	}
    
    	return new Image { Source = biSource };
    }					

    List Complete ( 1 snippet total )

    Cannot find what you were looking for?
    Ask the Snip2Code Community

    • Public Snippets
    • Channels Snippets