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

  • Question

  • User368437 posted

    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); }
        }`
    
    Thursday, February 14, 2019 4:43 PM

Answers

  • User369979 posted

    This is by design if you used the default system UIImagePickerController: https://stackoverflow.com/a/13167122/8354952 https://stackoverflow.com/questions/41706549/cant-pan-image-taken-from-camera-with-uiimagepicker It seems the edit box can be only stuck in the center position. So when you retrieve a square size image from the gallery, you can move the image to the top edge. But when you take a photo using UIImagePickerController, it is always a rectangle size you can't reach the longer side.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, February 15, 2019 8:52 AM

All replies

  • User369979 posted

    This is by design if you used the default system UIImagePickerController: https://stackoverflow.com/a/13167122/8354952 https://stackoverflow.com/questions/41706549/cant-pan-image-taken-from-camera-with-uiimagepicker It seems the edit box can be only stuck in the center position. So when you retrieve a square size image from the gallery, you can move the image to the top edge. But when you take a photo using UIImagePickerController, it is always a rectangle size you can't reach the longer side.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, February 15, 2019 8:52 AM
  • User368437 posted

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

    Friday, February 15, 2019 10:39 AM
  • User369979 posted

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

    Friday, February 15, 2019 10:42 AM
  • User368437 posted

    @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 .

    Friday, February 15, 2019 10:45 AM
  • User369979 posted

    @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.

    Friday, February 15, 2019 10:49 AM
  • User368437 posted

    @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 .

    Friday, February 15, 2019 10:53 AM