How to Save Image in Local Photos album of Windows Phone ?

Sometimes you may want to develop a windows phone app which containing many images to view like WallPaper app for Windows Phone LockScreen, Celebrity album, etc. It is quite easy to display images by using Image Control and passing source path to respective Image Control, but is it enough to just give functionality to see images only? The user always likes to keep good images on their phone. so, In that condition user should have an app that can provide the facility of saving images also. This blog simply shows how you can write code that would allow the user to save Image locally in their Save Image Photo album.

Implementation –

Here, you can see some piece of code which containing a function SaveImageToPhotoHub with few statements and a parameter type WriteableBitmap. This SaveImageToPhotoHub function returns either true or false output. To work with this function you just need to pass needed Image as parameter in SaveImageToPhotoHub function.


WriteableBitmap provides a BitmapSource that can be written to and updated. To declare WritableBitmap class you must include System.Windows.Media.Imaging namespace

using System.Windows.Media.Imaging;

MediaLibrary is a class which is used to access songs, playlists, and pictures in the device’s media library. To acess MediaLibrary class you need to include Microsoft.Xna.Framework.Media namespace

using Microsoft.Xna.Framework.Media;

SaveJpeg is an Extension method which is responsible to encodes a WriteableBitmap object into a JPEG stream, with parameters for setting the target width and height of the JPEG file.

SavePicture is a method of MediaLibrary class which saves the image contained in the stream object to the media library, and then returns that saved image as a picture object.

To acess MemoryStream class you need to include System.IO namespace.

using System.IO;

Now take a look how to use the above method for saving image.


Here, imgView is an Image Control which is placed in xaml part

Note :- To run this code properly your app should have capabilities to access Windows Phone windows phone media library hub. You can simply do this by checking ID_CAP_MEDIALIB_PHOTO from capabilities tab of WMAppManifest.xml

Isn’t it so easy to learn how to save the image locally on Windows Phone device? I hope you liked this article and this will help you while writing code for your app.

2 thoughts on “How to Save Image in Local Photos album of Windows Phone ?”

  1. loius says:

    I got it..
    Its supposed to be the name property of the Image you are saving
    Thanks again Ravi

  2. loius says:

    Thank for sharing this..
    just a question;
    is the imgview a component from the toolbox?

Leave a Reply