Steven
Steven

Reputation: 2208

Windows Phone 7 Convert MediaLibrary Picture to imagesource

How do I convert a Image stream from the Picture to an imagesource?

Im using this

  MediaLibrary library = new MediaLibrary();
                foreach (Picture Alb in library.Pictures)
                {
                    Z.ImageSource = Alb.GetImage();                        
                }

Upvotes: 0

Views: 1106

Answers (1)

Matt Lacey
Matt Lacey

Reputation: 65586

You'll need to turn the stream into an image to use it.

I'm not sure what z is in your example.
So, assuming you just wanted one image:

<Image x:Name="z" />

You could do:

var library = new MediaLibrary();

var picStream = library.Pictures.First();

var img = new BitmapImage();
img.SetSource(picStream.GetImage());

z.Source = img;

Upvotes: 1

Related Questions