Hello Developers,
I want to set background color of image when take image from gallery or take photo from camera.
i have some issue, when i set background color of content page is black and take transparency image from gallery, image have text color black after that not show anything because content page and image text color is black.
This is my take image code :
private async void ImageTapped(object sender, EventArgs e)
{
string action = await UserDialogs.Instance.ActionSheetAsync("PickPhoto", "Cancel", null, null, "Take Photo", "Pick From Gallery");
MediaFile file = null;
if (action == "Take Photo")
{
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
UserDialogs.Instance.Alert("No Camera", ":( No camera avaialble.", "OK");
return;
}
file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
Directory = "Sample",
Name = "test.png"
});
}
else if (action == "Pick From Gallery")
{
if (!CrossMedia.Current.IsPickPhotoSupported)
{
UserDialogs.Instance.Alert("PhotosNotSupported", "PermissionNotGrantedToPhotos.", "OK");
return;
}
else
{
file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
{
PhotoSize = PhotoSize.Medium
});
}
}
else
{
return;
}
if (file == null)
return;
Stream s = file.GetStream();
RestaurantImage.Source = ImageSource.FromStream(() =>
{
file.Dispose();
return s;
});
}