Ejemplo n.º 1
0
        public Task <byte[]> CropImageFromOriginalToBytes(string filePath)
        {
            var image          = UIImage.FromFile(filePath);
            var viewController = new TOCropViewController(TOCropViewCroppingStyle.Default, image);
            var ndelegate      = new CropVcDelegate(viewController);

            viewController.Delegate = ndelegate;

            viewController.PresentUsingRootViewController();
            var result = ndelegate.Task.ContinueWith(t => t).Unwrap();

            return(result);
        }
Ejemplo n.º 2
0
        public Task <byte[]> CropImageFromOriginalToBytes(string filePath, CropAspect aspect = CropAspect.Custom)
        {
            var image = UIImage.FromFile(filePath);

            //crop image
            var viewController = new TOCropViewController(TOCropViewCroppingStyle.Default, image);
            var ndelegate      = new CropVcDelegate(viewController);

            switch (aspect)
            {
            case CropAspect.Square:
                viewController.AspectRatioLockEnabled        = true;
                viewController.AspectRatioPickerButtonHidden = true;
                viewController.AspectRatioPreset             = TOCropViewControllerAspectRatioPreset.Square;
                break;
            }

            viewController.Delegate = ndelegate;
            //show
            viewController.PresentUsingRootViewController();
            var result = ndelegate.Task.ContinueWith(t => t).Unwrap();

            return(result);
        }