Working with High Resolution Images in Your Windows Phone Applications


With the emergence of better cameras in mobile phones, users are taking photos of increasingly higher resolutions. Image quality is getting better, and the image sizes are correspondingly increasing. High image quality shots take a lot of disk space, so it is important to be judicious when it comes to determining what resolution you want to store the images in your Camera roll.

The best camera in the mobile world is the one in Lumia 1020, which has a sensor size of 1/1.5”. The sensor supports 7712×5360 pixel resolution (41.3MP), and in 16:9 mode, a pixel size of 7712×4352 is supported (33.6 MP) and in 4:3 model, a pixel size of 7136 x 5360 (38.2MP) is supported.

A thing to note, by default a camera application might not store images at the highest possible resolution on the device and this is by design to avoid taking up all the storage space.

Instead, applications are recommended to take a photo at the higher resolution and it is scaled down to an acceptable image resolution (in an overexposed mode) to persist to the Camera Roll on the storage device (may be at a 5 MP resolution).

The typical steps of handling a high resolution image are:

1. Take a high resolution image and store it in your application local storage.

2. Scale down the image to a 5MP or lower resolution (in an overexposed mode).

3. Store the smaller image on the camera roll.

4. On a periodic basis, clear the application local storage.

How to Take High Resolution Images

To take a high resolution image, set the resolution of the PhotoCaptureDevice to the desired mode.

First, get the resolution of the camera.

var resolution = PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back);

If this is not the desired resolution, set it to the correct resolution desired for the image.

resolution = new Windows.Foundation.Size(resolutionWidth, resolutionHeight);
PhotoCaptureDevice device = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Back, resolution);

Once the photo is taken, store the high resolution image to the local storage. To do this, get the user store for the application using the GetUserStoreForApplication() API on the IsolatedStorageFile class,  and create a destination to store the image. Get the image as a stream by calling image.AsStream() and flush the contents of the file.

Next, to save the image to the camera roll, scale it down to an acceptable size with oversampling.

You can use the Nokia Imaging SDK to do this. You will convert the image to a BitMap and then scale it down.

Use the AutoResizeConfiguration API on the Nokia.Graphics.Imaging.AutoResizeConfiguration class to specify the desired resolution of the scaled image.

To save the image to the camera roll:

var library = new Microsoft.Xna.Framework.Media.MediaLibrary()
     using (var picture = library.SavePictureToCameraRoll(filenameBase, libraryImage))
	      savedPath = picture.GetPath();

Now, your scaled down image is in the camera roll.

The final step is the clear the isolated storage of your application.

You can delete the temporary files you have created upon application exit.

You can iterate over the entire isolated store and delete the files you don’t need by calling IsolatedStorageFile.DeleteFile() API.

Now, you have enabled your application to handle high resolution images.


In this article, we learned about handling high resolution images in your Windows Phone application. I hope you have found this information useful.

About the author

Vipul Patel is a Program Manager currently working at Amazon Corporation. He has formerly worked at Microsoft in the Lync team and in the .NET team (in the Base Class libraries and the Debugging and Profiling team). He can be reached at [email protected]

More by Author

Must Read