how to make the edge of the image taking move correctl in the Cropping after taking a photo : ios?

SoniaDevRootSoniaDevRoot Member ✭✭
edited February 14 in Xamarin.Forms

I have made this code to take photo and then crop using the UIImagePickerController but I got an issue when moving the image, I can't get the edge of the image in the crop rectangle. here is my code, is there anyone who get has an idea why it worked when piking an image from a gallery and it didn''t work when I used a camera?
` private void GotAccessToCamera(FileFormatEnum imageType, string imageId = null)
{
try
{
if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera))
{
imagePicker = new UIImagePickerController
{
SourceType = UIImagePickerControllerSourceType.Camera,
// MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera)
};
imagePicker.AllowsEditing = true;
imagePicker.EdgesForExtendedLayout =UIRectEdge.None;
var window = UIApplication.SharedApplication.KeyWindow;
var vc = window.RootViewController;
while (vc.PresentedViewController != null)
{
vc = vc.PresentedViewController;
}
vc.PresentViewController(imagePicker, true, null);

                imagePicker.FinishedPickingMedia += (sender, e) =>
                {
                    UIImage image = (UIImage)e.Info.ObjectForKey(new NSString("UIImagePickerControllerEditedImage"));
                    Data = null;
                    if (imageType == FileFormatEnum.PNG)
                        Data = image.AsPNG();
                    else
                        Data = image.AsJPEG();
                    byte[] myByteArray = new byte[Data.Length];
                };
           }

        }
        catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); }
    }`

Best Answer

Answers

  • SoniaDevRootSoniaDevRoot Member ✭✭

    @LandLu in other word I should just create a cropping tools customized for me in the case of the camera

  • LandLuLandLu Member, Xamarin Team Xamurai

    @SoniaDevRoot Search the appropriate picker plugin you need on GitHub. Or customize the whole control by yourself.

  • SoniaDevRootSoniaDevRoot Member ✭✭

    @LandLu thnx a lot for your answer , actually I did a cropping tools but since the image was not with good quality I decided to use the native feature, but it was a bad idea after all .

  • LandLuLandLu Member, Xamarin Team Xamurai

    @SoniaDevRoot It's hard to say this is a bad idea. Everyone has its own requirement, maybe Apple just thinks that it is a better behavior for keeping the editor box in the center position.
    And yes, you have made your own effort to do what you want. It's also a good experience.

  • SoniaDevRootSoniaDevRoot Member ✭✭

    @LandLu true I did learn many things while trying to create the cropping tool ,Ill just try again to see what's I did wrong there .

Sign In or Register to comment.