isolated

Isolated Storage in Windows phone app – Reading and saving images

This is the fourth post regarding Isolated Storage in Windows Phone app. In this post I am going to talk about How to read and save captured images in isolated storage.

Note: To understand this post better you should test the following code on a real phone not an emulator as camera of emulator will give you a black screen.

 

1. Before starting with this post you should have a better understanding of Photochoosertask and CameraCaptureTask.

 

If you don’t have any idea about these tasks you can refer to the following post.

http://www.windowsapptutorials.com/launchers-and-choosers/launchers-and-choosers-how-to-choose-photo-from-media-library-or-capture-a-new-one-in-windows-phone-app/

 

2. In the following post first I will explain you how to save and read the image chosen from medial library into isolated storage. Then I will explain you how to save the image captured from camera into the isolated storage and how you can read that image from isolated storage.

 

Both the tasks have similar code for saving and reading the image except the code for launching the tasks.

 

3. First create a blank project Saveimages.

 


 

4. Add the following namespaces to the page MainPage.xaml.cs.

 

 
5. Now first we will launch the photochoosertask and will select a image from media library and will save it to isolated storage.

 

Save the existing image

First create a button to save the existing image and add the following code to click event handler of the button.

 

 
The Task completed event handler of the choosertask will save the image to the isolated storage having the file name existing.jpg. The code is given below.

 

 

Now you can read the image from isolated storage and display it in the imagecontrol given on the MainPage by clicking on the read selected image button. The following code is given below.

 

 

Save the captured image

The procedure for the CameraCapturetask is same as that of photochooser. We will create a button to launch the CameraCapturetask and will save the captured image in isolated storage having the name captured.jpg.

 

 

 

 

We can read the captured image in the same way as we did for the Photochooser task. The code for the read captured image button is as shown below.

 

 

Note: You will observe that the code for both the tasks will be similar as there is no difference between the read save image code of both the tasks except the filename.

 

 

 

6. I hope this post will be helpful to you. You can download the full project source file from the link given below.

 
Download Full Project file Saveimages.zip
 
 
Isolated Storage in Windows Phone app – Introduction
Isolated Storage in Windows phone app – Store data in IsolatedStorageSettings
Isolated Storage in Windows phone app – Reading and saving text files

Chetan Gulati

Currently am doing B TECH in IT from Delhi Technological University. App development is my passion. Believe in quality rather than quantity.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close