locked
how to extract image and load it on windows 8 app realtime.

    Question

  • hi folks..

    im trying to load pic in my xaml sheet dynamically for which im using sql DB, but im not able to get the syntax to do the same in c#. can u help me with an example to do the same. im using{ byte[] data_image = Convert.FromBase64String("image string to store the image in  db"); }to extract the image content from the DB.

    please suggest any easy way to do the same.


    justin


    Tuesday, January 01, 2013 6:54 AM

Answers

  • here it is folks...

    i got it with the help of a colleague.. thanks to her..

    private async void GetDynamicImage()
            {
                byte[] data_image = Convert.FromBase64String("image data stored as string");
                InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();
                DataWriter dw = new DataWriter(ras.GetOutputStreamAt(0));
                dw.WriteBytes(data_image);
                await dw.StoreAsync();
                BitmapImage bImg = new BitmapImage();
                bImg.SetSource(ras);
                if (bImg != null)
                {
                    img1.Source = bImg; //img1 is the image control in the XAML file.
                }
            }

    thanks...

    cherian


    justin

    Friday, January 04, 2013 6:58 AM