Skip to content

Instantly share code, notes, and snippets.

@FrayxRulez
Last active July 5, 2017 16:18
Show Gist options
  • Save FrayxRulez/c2f1bbfa996ad5751b87 to your computer and use it in GitHub Desktop.
Save FrayxRulez/c2f1bbfa996ad5751b87 to your computer and use it in GitHub Desktop.
private async Task CropImage()
{
// Create destination file and obtain sharing token
var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("Cropped.jpg", CreationCollisionOption.ReplaceExisting);
var token = SharedStorageAccessManager.AddFile(file);
// Specify the app to launch using LaunchUriForResults
var options = new LauncherOptions();
options.TargetApplicationPackageFamilyName = "Microsoft.Windows.Photos_8wekyb3d8bbwe";
// Specify all the parameters
var parameters = new ValueSet();
parameters.Add("CropWidthPixels", 500);
parameters.Add("CropHeightPixels", 500);
parameters.Add("EllipticalCrop", true);
parameters.Add("ShowCamera", false);
parameters.Add("DestinationToken", token);
// Launches the app and wait for results
var result = await Launcher.LaunchUriForResultsAsync(new Uri("microsoft.windows.photos.crop:"), options, parameters);
// Check if the user has really cropped the picture
if (result.Status == LaunchUriStatus.Success && result.Result != null)
{
// Loads the picture
var stream = await file.OpenReadAsync();
var bitmap = new BitmapImage();
await bitmap.SetSourceAsync(stream);
// Set the picture as Source of an Image control
Preview.Source = bitmap;
}
}
@lancecontreras
Copy link

I would also like to us LaunchUriForResultsAsync to launch my other app. My problem is that it only launches another app in 500x500 window size. I need something bigger than that. Is it possible to make it full screen or maybe any size bigger than 500?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment