Saving Embedded Images for Windows Phone 7
This sample shows how to transfer application images to a Windows Phone 7 media library.Sample Overview
Saving Embedded Images for Windows Phone 7 shows how to move image resources from both the game project and content project to a phone's media library. This sample also shows how to work with the Guide text input and output APIs, BeginShowKeyboard and BeginShowMessageBox, respectively.
Sample Controls
This sample uses on-screen UI. The phone's back button also can be used to exit the sample.
How the Sample Works
The Saving Embedded Images sample illustrates two different methods for handling image resources that are part of an application's XAP file.
One image is part of the game project. It is loaded with the TitleContainer.OpenStream method, and converted into a texture for display with Texture2D.FromStream.
The second image is part of the application's content project, and is loaded with ContentManager.Load<Texture2D>.
Both images can be saved to the user's media library. The image stream acquired from TitleContainer.OpenStream can be sent directly to MediaLibrary.SavePicture. The content project image loaded into a Texture2D is first stored in a MemoryStream with Texture2D.SaveAsJpeg, and then the stream can be passed to the media library.
Extending the Sample
Developers could explore additional ways of working with image media, such as loading and saving pictures to the application's IsolatedStorage, retrieving existing pictures from the photo collection by using PhotoChooserTask, and acquiring photos from the phone's camera by using CameraCaptureTask.