×

Discussion Board

Results 1 to 10 of 10

Threaded View

  1. #1
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    145

    How to load recent images from the media library?

    Here is my class to get recent photos from media library..

    Code:
       public class RecentPhoto
        {
            public string FilePath { get; private set; }
    
            public BitmapImage Thumbnail
            {
                get
                {
                    var width = 226.0 * (Application.Current.Host.Content.ScaleFactor / 100.0);
    
                    return new BitmapImage(new Uri(FilePath, UriKind.Relative)) { DecodePixelWidth = (int)width };
                }
            }
    
            public RecentPhoto(string file)
            {
                FilePath = file;
            }
        }
    
        public class RecentPhotos
        {
            public static List<string> GetPaths()
            {
                List<string> ImagePaths = new List<string>();
    
                using (MediaLibrary library = new MediaLibrary())
                {
                    foreach (var item in library.Pictures.Reverse().Take(3))
                    {
                        ImagePaths.Add(item.GetPath());
                    }
                }
    
                return ImagePaths;
            }
    
            public RecentPhoto Photo1 { get; private set; }
            public RecentPhoto Photo2 { get; private set; }
            public RecentPhoto Photo3 { get; private set; }
    
            public void Initialize()
            {
                var path = RecentPhotos.GetPaths();
    
                if (path.Count > 0)
                {
                    Photo1 = new RecentPhoto(path[0]);
                    Photo2 = new RecentPhoto(path[1]);
                    Photo3 = new RecentPhoto(path[2]);
                }
            }
        }
    Here is my project, any answer will be highly appreciated!

    Thank you
    Last edited by venu238; 2014-04-14 at 19:56.
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

Similar Threads

  1. How to save png to media library?
    By venu238 in forum Windows Phone Imaging
    Replies: 7
    Last Post: 2014-03-08, 16:54
  2. Load images from library to empty movie clip
    By elminator in forum [Archived] Flash Lite on Nokia Devices
    Replies: 7
    Last Post: 2011-04-21, 07:55
  3. Dll library load error -46
    By komicek in forum Symbian
    Replies: 2
    Last Post: 2008-06-21, 09:16
  4. failed to load library
    By felixksp in forum Symbian
    Replies: 15
    Last Post: 2007-07-23, 20:19
  5. External Media Library
    By desijatt in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2006-09-27, 00:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×