0

How can we use Pictures/RootPictureAlbum/SavedPicture API of MediaLibrary class to access the photos in SavedPicture folder to read them into byte buffer?

prince
  • 1,129
  • 1
  • 15
  • 38

1 Answers1

1

Try by this way

        using (var library = new MediaLibrary())
        {

            var savedPictures = library.Pictures.ToList();
            if (savedPictures.Any())
            {
                foreach (var pic in savedPictures)
                {
                    var bitmap = new WriteableBitmap(pic.Width, pic.Height);
                    using (var stream = pic.GetImage()) //here you will get the stream
                    {

                        bitmap.SetSource(stream);                           

                    }
                }
            }
        }
asitis
  • 3,023
  • 1
  • 31
  • 55
  • Thank you Asitis it worked.Previously I've saved a picture into CameraRoll and with the above code I was able to retrieve the picture, but now the problem is while saving and retrieving, the buffer size is totally different, What would be the possible reason for this? – prince Jan 02 '14 at 06:59
  • What is the buffer size difference you mean? – asitis Jan 02 '14 at 07:10
  • I've converted stream to byte array before saving and also after retrieving, the length of these byte arrays is different? – prince Jan 02 '14 at 07:13
  • If you want to get the exact image use pic.GetImage() instead of pic.GetThumbnail() – asitis Jan 02 '14 at 07:15
  • I've used GetImage() only. I just wanted to know how the size of the image is increasing after saving it to the camera roll. – prince Jan 02 '14 at 07:19
  • add it in your question , so that others can understand your problem easily. – asitis Jan 02 '14 at 07:20
  • My problem got solved. It was the problem of file format. I was saving the file in different format, that is why it showed different file sizes. – prince Jan 02 '14 at 10:17