public static BitmapImage GetDecodedBitmapImage(Photo photo, DecodeResolutions res)
 {
     if (res == DecodeResolutions.High)
     {
         return new BitmapImage { UriSource = new Uri(photo.GetImageUrl()), DecodePixelWidth = 640 };
     }
     else if (res == DecodeResolutions.Medium)
     {
         return new BitmapImage { UriSource = new Uri(photo.GetImageUrl()), DecodePixelWidth = 480 };
     }
     else
     {
         return new BitmapImage { UriSource = new Uri(photo.GetImageUrl()), DecodePixelWidth = 240 };
     }
 }
        private void AddDownloadRequest(Photo photo, int index)
        {
            if (BackgroundTransferService.Requests.Count() >= MAX_TILE_IMAGE_COUNT)
            {
                return;
            }

            string filename = "tile" + index.ToString() + ".jpg";

            Uri transferUri = new Uri(photo.GetImageUrl(), UriKind.Absolute);

            // Create the new transfer request, passing in the URI of the file to
            // be transferred.
            BackgroundTransferRequest transferRequest = new BackgroundTransferRequest(transferUri);

            // Set the transfer method. GET and POST are supported.
            transferRequest.Method = "GET";

            // Set download location uri
            transferRequest.DownloadLocation = new Uri("shared/transfers/" + filename, UriKind.RelativeOrAbsolute);
            transferRequest.TransferStatusChanged += new EventHandler<BackgroundTransferEventArgs>(transfer_TransferStatusChanged);
            transferRequest.Tag = filename;
            ProcessTransfer(transferRequest);

            // Start request
            try
            {
                BackgroundTransferService.Add(transferRequest);
            }
            catch (InvalidOperationException ex)
            {
                System.Diagnostics.Debug.WriteLine("Unable to add background transfer request. " + ex.Message);
            }
            catch (Exception)
            {
                System.Diagnostics.Debug.WriteLine("Unable to add background transfer request.");
            }
        }