Last active
July 5, 2017 16:18
-
-
Save FrayxRulez/c2f1bbfa996ad5751b87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?