Alex-Dobrynin / Xamarin.Controls.ImageCropper

Cross platform Xamarin library to crop and rotate images
MIT License
8 stars 2 forks source link

iOS: Cropped image is not showing #2

Closed AlanFloyd closed 2 years ago

AlanFloyd commented 2 years ago

Hello,

trying to use the control. As Android is working fine, opens the image, can crop it and it is showing up in the activity. But on iOS it is not working in the same way, the image is opened, it can be cropped, but it is not showing in the activity. In debugger i can see: 1. return isCompleted = true, t.result shows the path to the Document directory and the corresponding cropped jpg, i assign image.Source = result, but the image is not shown on screen

Thanks for help Dietmar

Alex-Dobrynin commented 2 years ago

Could you provide test project which reproduces this issue

AlanFloyd commented 2 years ago

This is the code I am using:

void crop_image(String PhotoPath)
        {
            _ = ImageCropper.Current.Crop(new CropSettings()
            {
                AspectRatioX = 1,
                AspectRatioY = 1,
                CropShape = CropSettings.CropShapeType.Rectangle
            }, PhotoPath).ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    var ex = t.Exception;
                    //alert user
                }
                else if (t.IsCanceled)
                {
                    var ex = t.Exception;
                    //do nothing
                }
                else if (t.IsCompleted)
                {
                    var result = t.Result;
                    image.Source = result;
                    is_saved = false;
                }
            });
        }

PhotoPath has a valid path. Also the bool is_saved is not updated, this happens only on iOS. On Android it works fine. I am using Visual Studio for Mac 8.9.10 (build 4)

AlanFloyd commented 2 years ago

Hi Alex,

i found it:

Device.BeginInvokeOnMainThread(() =>
                    {
                        image.Source = result;
                        is_saved = false;
                    });