Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am working on Windows 8 store application. I am new at it.

I am receiving an image in the form of byte array (byte []).

I have to convert this back to Image and display it in Image Control.

so far I have button and Image control on Screen. When I click button, I call following function

C#
private async Task LoadImageAsync()
{
    byte[] code = //call to third party API for byte array
    System.IO.MemoryStream ms = new MemoryStream(code);
    var bitmapImg = new Windows.UI.Xaml.Media.Imaging.BitmapImage();

    Windows.Storage.Streams.InMemoryRandomAccessStream imras = new Windows.Storage.Streams.InMemoryRandomAccessStream();

    Windows.Storage.Streams.DataWriter write = new Windows.Storage.Streams.DataWriter(imras.GetOutputStreamAt(0));
    write.WriteBytes(code);
    await write.StoreAsync();
    bitmapImg.SetSourceAsync(imras);
    pictureBox1.Source = bitmapImg;
}



This is not working properly. any idea?
When I debug, I can see the byte array in ms. but it is not getting converted to bitmapImg.
Posted
Comments
Abdul Muneeb Abbasi 5-Mar-14 8:08am    
Any suggestions please?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900