so, I've implemented the media picker from Xamarin.Essentials to capture from camera. works in iOS, android and UWP. nice!
but i'm not sure how to proceed. on iOS and android, when i take the photo in portrait mode, the image is rotated 90 degrees.
don't feel i should educate the user in app to rotate the phone to take the picture.
a) how to force the native camera's pic to stay in the orientation it was taken?
b) whether "a" happens or not, how to allow user to then and there rotate and crop image before it becomes the official image to be used? (trying to not use 3rd party stuff. trying to stay very xamarin-basics as much as possible.)
thanks.
XAML:
<Entry x:Name="UPC" Placeholder="[passed in UPC string]"/>
<Entry x:Name="ProductName" Placeholder="Flite"/>
<Entry x:Name="Count" Placeholder="15"/>
<Entry x:Name="SellPrice" Placeholder="0"/>
<Entry x:Name="BaseBuyingPrice" Placeholder="0"/>
<Button x:Name="CameraButton" Text="Take Image" Clicked="CameraButton_Clicked" />
<Image x:Name="resultImage" />
<Button x:Name="SaveProduct" Text="Save Product" Clicked="SaveProduct_Clicked"/>
C#:
private async void CameraButton_Clicked(System.Object sender, System.EventArgs e)
{
var result = await MediaPicker.CapturePhotoAsync();
if (result != null)
{
var stream = await result.OpenReadAsync();
resultImage.Source = ImageSource.FromStream(() => stream);
}
}
private void SaveProduct_Clicked(object sender, EventArgs e)
{
//add this product and all its fields to the database with the UPC string as the key/unique identifier
Navigation.PushAsync(new AllProductsPage());
}