Exemple #1
0
        private void CropImage()
        {
            var croppedFile    = CreateTempFile(_cacheDir, "cropped");
            var destinationUri = AndroidUri.FromFile(croppedFile);
            var options        = new UCrop.Options();

            // applying UI theme
            options.SetToolbarColor(ContextCompat.GetColor(this, Resource.Color.colorPrimary));
            options.SetStatusBarColor(ContextCompat.GetColor(this, Resource.Color.colorPrimary));
            options.SetActiveControlsWidgetColor(ContextCompat.GetColor(this, Resource.Color.colorPrimary));
            options.WithAspectRatio(1, 1);
            options.WithMaxResultSize(2000, 2000);
            options.SetCompressionQuality(80);

            UCrop.Of(_photoUri, destinationUri)
            .WithOptions(options)
            .Start(this);
        }
        private void CropImage(Uri selectedImageURI)
        {
            Uri destinationUri = Uri.FromFile(new File(Context.CacheDir, QueryName(Context.ContentResolver, selectedImageURI)));

            UCrop.Options options = new UCrop.Options();
            options.SetCompressionQuality(IMAGE_COMPRESSION);
            options.SetToolbarColor(ContextCompat.GetColor(Context, Resource.Color.colorPrimary));
            options.SetStatusBarColor(ContextCompat.GetColor(Context, Resource.Color.colorPrimaryDark));
            options.SetActiveControlsWidgetColor(ContextCompat.GetColor(Context, Resource.Color.colorAccent));

            if (lockAspectRatio)
            {
                options.WithAspectRatio(ASPECT_RATIO_X, ASPECT_RATIO_Y);
            }

            if (setBitmapMaxWidthHeight)
            {
                options.WithMaxResultSize(bitmapMaxWidth, bitmapMaxHeight);
            }

            UCrop.Of(selectedImageURI, destinationUri)
            .WithOptions(options)
            .Start(Context, this, UCROP_REQUEST);
        }