Loading, iterating, and saving photos with WP7

medialib_Sample_Screenshot[1] Friend of Coding4Fun, René Schulte, has an full write-up on how to do some simple drawing, loading, and saving with Windows Phone 7.  René even used multi-touch as well!

He leverages the WriteableBitmapEx class that extends out the WriteableBitmap Silverlight class.

To do a PhotoChooser, the code is simpler than one may think.  Since you're app will navigate away, it works with events.

public MainPage()
{
   // ...

   // Init chooser
   photoChooserTask = new PhotoChooserTask();
   photoChooserTask.Completed += PhotoChooserTaskCompleted;
   
   // ...
}

private void ApplicationBarIconOpenButton_Click(object sender, EventArgs e)
{
   photoChooserTask.Show();
}

private void PhotoChooserTaskCompleted(object sender, PhotoResult e)
{
   if (e.TaskResult == TaskResult.OK)
   {
      // Load original image and invalidate bitmap so it gets newly rendered
      var bitmapImage = new BitmapImage();
      bitmapImage.SetSource(e.ChosenPhoto);
      Viewport.Source = bitmapImage;
      bitmap = null;
   }
}

Tags:

Follow the Discussion

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.