Java Code Examples for com.yalantis.ucrop.UCrop#Options
The following examples show how to use
com.yalantis.ucrop.UCrop#Options .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImagePickerActivity.java From Android-Image-Picker-and-Cropping with GNU General Public License v3.0 | 6 votes |
private void cropImage(Uri sourceUri) { Uri destinationUri = Uri.fromFile(new File(getCacheDir(), queryName(getContentResolver(), sourceUri))); UCrop.Options options = new UCrop.Options(); options.setCompressionQuality(IMAGE_COMPRESSION); // applying UI theme options.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary)); options.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimary)); options.setActiveWidgetColor(ContextCompat.getColor(this, R.color.colorPrimary)); if (lockAspectRatio) options.withAspectRatio(ASPECT_RATIO_X, ASPECT_RATIO_Y); if (setBitmapMaxWidthHeight) options.withMaxResultSize(bitmapMaxWidth, bitmapMaxHeight); UCrop.of(sourceUri, destinationUri) .withOptions(options) .start(this); }
Example 2
Source File: BoxingUcrop.java From boxing with Apache License 2.0 | 6 votes |
@Override public void onStartCrop(Context context, Fragment fragment, @NonNull BoxingCropOption cropConfig, @NonNull String path, int requestCode) { Uri uri = new Uri.Builder() .scheme("file") .appendPath(path) .build(); UCrop.Options crop = new UCrop.Options(); // do not copy exif information to crop pictures // because png do not have exif and png is not Distinguishable crop.setCompressionFormat(Bitmap.CompressFormat.PNG); crop.withMaxResultSize(cropConfig.getMaxWidth(), cropConfig.getMaxHeight()); crop.withAspectRatio(cropConfig.getAspectRatioX(), cropConfig.getAspectRatioY()); UCrop.of(uri, cropConfig.getDestination()) .withOptions(crop) .start(context, fragment, requestCode); }
Example 3
Source File: CropUtils.java From CropUtils with Apache License 2.0 | 6 votes |
private static void startCropActivity(Activity context, Uri sourceUri) { Uri mDestinationUri = buildUri(); UCrop uCrop = UCrop.of(sourceUri, mDestinationUri); uCrop.withAspectRatio(config.aspectRatioX,config.aspectRatioY); uCrop.withMaxResultSize(config.maxWidth,config.maxHeight); UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.JPEG); options.setAllowedGestures(UCropActivity.SCALE,UCropActivity.NONE,UCropActivity.NONE); options.setCompressionQuality(config.quality); options.setOvalDimmedLayer(config.isOval); options.setShowCropGrid(config.showGridLine); options.setHideBottomControls(config.hideBottomControls); options.setShowCropFrame(config.showOutLine); options.setToolbarColor(config.toolbarColor); options.setStatusBarColor(config.statusBarColor); uCrop.withOptions(options); uCrop.start(context); }
Example 4
Source File: PhotoPickerActivity.java From PhotoPicker with Apache License 2.0 | 6 votes |
public void openCropActivity(String path) { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.ENGLISH).format(new Date()); String imageFileName = "JPEG_" + timeStamp + ".jpg"; UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.JPEG); options.setHideBottomControls(true); options.setFreeStyleCropEnabled(false); options.setCompressionQuality(90); options.setToolbarColor(ContextCompat.getColor(this, toolbarColor)); options.setStatusBarColor(ContextCompat.getColor(this, statusbarColor)); UCrop.of(Uri.fromFile(new File(path)), Uri.fromFile(new File(getActivity().getCacheDir(), imageFileName))) .withAspectRatio(cropX, cropY) .withOptions(options) .start(PhotoPickerActivity.this); }
Example 5
Source File: PicCrop.java From PicCrop with Apache License 2.0 | 6 votes |
private static void startCropActivity(Activity context, Uri sourceUri) { Uri mDestinationUri = buildUri(); UCrop uCrop = UCrop.of(sourceUri, mDestinationUri); uCrop.withAspectRatio(config.aspectRatioX,config.aspectRatioY); uCrop.withMaxResultSize(config.maxWidth,config.maxHeight); UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.JPEG); options.setAllowedGestures(UCropActivity.SCALE,UCropActivity.NONE,UCropActivity.NONE); options.setCompressionQuality(config.quality); // options.setOvalDimmedLayer(config.isOval); options.setCircleDimmedLayer(config.isOval); options.setShowCropGrid(config.showGridLine); options.setHideBottomControls(config.hideBottomControls); options.setShowCropFrame(config.showOutLine); options.setToolbarColor(config.toolbarColor); options.setStatusBarColor(config.statusBarColor); uCrop.withOptions(options); uCrop.start(context); }
Example 6
Source File: PhotoEditorActivity.java From react-native-photo-editor with Apache License 2.0 | 6 votes |
private void startCropping() { System.out.println(selectedImagePath); Uri uri = Uri.fromFile(new File(selectedImagePath)); UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.JPEG); options.setCompressionQuality(100); options.setCircleDimmedLayer(cropperCircleOverlay); options.setFreeStyleCropEnabled(freeStyleCropEnabled); options.setShowCropGrid(showCropGuidelines); options.setHideBottomControls(hideBottomControls); options.setAllowedGestures( UCropActivity.ALL, // When 'scale'-tab active UCropActivity.ALL, // When 'rotate'-tab active UCropActivity.ALL // When 'aspect ratio'-tab active ); UCrop uCrop = UCrop .of(uri, Uri.fromFile(new File(this.getTmpDir(this), UUID.randomUUID().toString() + ".jpg"))) .withOptions(options); uCrop.start(this); }
Example 7
Source File: PictureBaseActivity.java From PictureSelector with Apache License 2.0 | 6 votes |
/** * single crop * * @param originalPath * @param cachePath * @param mimeType * @param options */ private void startSingleCropActivity(String originalPath, String cachePath, String mimeType, UCrop.Options options) { boolean isHttp = PictureMimeType.isHasHttp(originalPath); String suffix = mimeType.replace("image/", "."); File file = new File(PictureFileUtils.getDiskCacheDir(getContext()), TextUtils.isEmpty(config.renameCropFileName) ? DateUtils.getCreateFileName("IMG_CROP_") + suffix : config.renameCropFileName); Uri uri; if (!TextUtils.isEmpty(cachePath)) { uri = Uri.fromFile(new File(cachePath)); } else { uri = isHttp || SdkVersionUtils.checkedAndroid_Q() ? Uri.parse(originalPath) : Uri.fromFile(new File(originalPath)); } UCrop.of(uri, Uri.fromFile(file)) .withOptions(options) .startAnimationActivity(this, config.windowAnimationStyle != null ? config.windowAnimationStyle.activityCropEnterAnimation : R.anim.picture_anim_enter); }
Example 8
Source File: PhotoActivity.java From CrazyDaily with Apache License 2.0 | 6 votes |
/** * 其它配置 */ private UCrop advancedConfig(@NonNull UCrop uCrop) { UCrop.Options options = new UCrop.Options(); switch (mCropCompressRadioGroup.getCheckedRadioButtonId()) { case R.id.photo_crop_compress_png: options.setCompressionFormat(Bitmap.CompressFormat.PNG); break; case R.id.photo_crop_compress_jpg: default: options.setCompressionFormat(Bitmap.CompressFormat.JPEG); break; } options.setCompressionQuality(getCompressionQuality()); options.setHideBottomControls(mCropUISetting.isChecked()); options.setFreeStyleCropEnabled(mCropRatioFreestyle.isChecked()); options.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary)); options.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark)); options.setActiveWidgetColor(ContextCompat.getColor(this, R.color.colorPrimary)); options.setToolbarWidgetColor(ContextCompat.getColor(this, R.color.color_white)); return uCrop.withOptions(options); }
Example 9
Source File: PictureBaseActivity.java From PictureSelector with Apache License 2.0 | 6 votes |
/** * crop * * @param originalPath * @param mimeType */ protected void startCrop(String originalPath, String mimeType) { if (DoubleUtils.isFastDoubleClick()) { return; } if (TextUtils.isEmpty(originalPath)) { ToastUtils.s(this, getString(R.string.picture_not_crop_data)); return; } UCrop.Options options = basicOptions(); if (PictureSelectionConfig.cacheResourcesEngine != null) { PictureThreadUtils.executeByIo(new PictureThreadUtils.SimpleTask<String>() { @Override public String doInBackground() { return PictureSelectionConfig.cacheResourcesEngine.onCachePath(getContext(), originalPath); } @Override public void onSuccess(String result) { startSingleCropActivity(originalPath, result, mimeType, options); } }); } else { startSingleCropActivity(originalPath, null, mimeType, options); } }
Example 10
Source File: PhotoPickerActivity.java From PhotoPicker with Apache License 2.0 | 5 votes |
public void openCropActivity(String path) { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.ENGLISH).format(new Date()); String imageFileName = "JPEG_" + timeStamp + ".jpg"; UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.JPEG); options.setHideBottomControls(true); options.setFreeStyleCropEnabled(false); options.setCompressionQuality(100); options.setToolbarColor(ContextCompat.getColor(this,toolbarColor)); options.setStatusBarColor(ContextCompat.getColor(this, statusbarColor)); UCrop.of(Uri.fromFile(new File(path)), Uri.fromFile(new File(getActivity().getCacheDir(), imageFileName))) .withAspectRatio(cropX, cropY) .withOptions(options) .start(PhotoPickerActivity.this); }
Example 11
Source File: PictureActivity.java From AndroidSamples with Apache License 2.0 | 5 votes |
/** * 使用UCrop进行图片剪裁 * * @param uri */ public void cropRawPhoto(Uri uri) { UCrop.Options options = new UCrop.Options(); // 修改标题栏颜色 options.setToolbarColor(getResources().getColor(R.color.colorPrimary)); // 修改状态栏颜色 options.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark)); // 隐藏底部工具 options.setHideBottomControls(true); // 图片格式 options.setCompressionFormat(Bitmap.CompressFormat.JPEG); // 设置图片压缩质量 options.setCompressionQuality(100); // 是否让用户调整范围(默认false),如果开启,可能会造成剪切的图片的长宽比不是设定的 // 如果不开启,用户不能拖动选框,只能缩放图片 options.setFreeStyleCropEnabled(true); // 设置图片压缩质量 options.setCompressionQuality(100); // 圆 options.setCircleDimmedLayer(true); // 不显示网格线 options.setShowCropGrid(false); FileUtils.createOrExistsDir(Config.SAVE_REAL_PATH); // 设置源uri及目标uri UCrop.of(uri, Uri.fromFile(new File(Config.SAVE_REAL_PATH, System.currentTimeMillis() + ".jpg"))) // 长宽比 .withAspectRatio(1, 1) // 图片大小 .withMaxResultSize(200, 200) // 配置参数 .withOptions(options) .start(this); }
Example 12
Source File: PostImage.java From Hify with MIT License | 5 votes |
public void openCropItem(View view) { selectedIndex=pager.getCurrentItem(); UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.PNG); options.setCompressionQuality(75); options.setShowCropGrid(true); UCrop.of(Uri.fromFile(new File(imagesList.get(selectedIndex).getOg_path())), Uri.fromFile(new File(getCacheDir(), imagesList.get(selectedIndex).getName() + "_" + random() + "_edit.png"))) .withAspectRatio(1, 1) .withOptions(options) .start(this); }
Example 13
Source File: SingleMediaActivity.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("ResourceAsColor") private UCrop.Options getUcropOptions() { UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.PNG); options.setCompressionQuality(90); options.setActiveControlsWidgetColor(getAccentColor()); options.setToolbarColor(getPrimaryColor()); options.setStatusBarColor(isTranslucentStatusBar() ? ColorPalette.getObscuredColor(getPrimaryColor()) : getPrimaryColor()); options.setCropFrameColor(getAccentColor()); options.setFreeStyleCropEnabled(true); return options; }
Example 14
Source File: EasyPhotosActivity.java From EasyPhotos with Apache License 2.0 | 4 votes |
private void startCrop(AppCompatActivity context, Photo photo, Intent data) { String source = photo.path; BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(source, bitmapOptions); if (bitmapOptions.outWidth == -1 || bitmapOptions.outHeight == -1) { setResult(RESULT_OK, data); finish(); Log.e("EasyPhotos", "该类型不支持裁剪!"); return; } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HH:mm:ss", Locale.getDefault()); // String suffix = source.substring(source.lastIndexOf(".")); String imageName = "IMG_CROP_%s" + getImageSuffix(photo.type); String destinationFileName = String.format(imageName, dateFormat.format(new Date())); UCrop.Options options = new UCrop.Options(); //设置相关颜色 int statusBarColor = ContextCompat.getColor(this, R.color.easy_photos_status_bar); if (ColorUtils.isWhiteColor(statusBarColor)) { statusBarColor = Color.LTGRAY; } options.setStatusBarColor(statusBarColor); int barColor = ContextCompat.getColor(this, R.color.easy_photos_bar_primary); options.setToolbarColor(barColor); int widgetColor = ContextCompat.getColor(this, R.color.easy_photos_fg_primary); options.setToolbarWidgetColor(widgetColor); options.setActiveWidgetColor(Color.BLACK); //options.setLogoColor(Color.TRANSPARENT); //设置裁剪质量 options.setCompressionQuality(Setting.compressQuality); //是否圆形裁剪 options.setCircleDimmedLayer(Setting.isCircle); //设置网格相关 options.setShowCropFrame(Setting.isShowCropCropFrame); options.setShowCropGrid(Setting.isShowCropGrid); //是否自由裁剪 options.setFreeStyleCropEnabled(Setting.isFreeStyleCrop); //设置title options.setToolbarTitle("裁剪"); //隐藏底部控制栏 options.setHideBottomControls(Setting.isHideUCropControls); //toolbar options.setToolbarCancelDrawable(R.drawable.ic_arrow_back_easy_photos); Uri uri; if (SystemUtils.beforeAndroidTen()) { uri = Uri.fromFile(new File(source)); } else { uri = Uri.parse(source); } File cacheFile = new File(context.getCacheDir(), destinationFileName); UCrop.of(uri, Uri.fromFile(cacheFile)) .withAspectRatio(Setting.aspectRatio[0], Setting.aspectRatio[1]) .withOptions(options) .start(context); }
Example 15
Source File: ActivityRxPhoto.java From RxTools-master with Apache License 2.0 | 4 votes |
private void initUCrop(Uri uri) { //Uri destinationUri = RxPhotoTool.createImagePathUri(this); SimpleDateFormat timeFormatter = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA); long time = System.currentTimeMillis(); String imageName = timeFormatter.format(new Date(time)); Uri destinationUri = Uri.fromFile(new File(getCacheDir(), imageName + ".jpeg")); UCrop.Options options = new UCrop.Options(); //设置裁剪图片可操作的手势 options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.ROTATE, UCropActivity.ALL); //设置隐藏底部容器,默认显示 //options.setHideBottomControls(true); //设置toolbar颜色 options.setToolbarColor(ActivityCompat.getColor(this, R.color.colorPrimary)); //设置状态栏颜色 options.setStatusBarColor(ActivityCompat.getColor(this, R.color.colorPrimaryDark)); //开始设置 //设置最大缩放比例 options.setMaxScaleMultiplier(5); //设置图片在切换比例时的动画 options.setImageToCropBoundsAnimDuration(666); //设置裁剪窗口是否为椭圆 //options.setOvalDimmedLayer(true); //设置是否展示矩形裁剪框 // options.setShowCropFrame(false); //设置裁剪框横竖线的宽度 //options.setCropGridStrokeWidth(20); //设置裁剪框横竖线的颜色 //options.setCropGridColor(Color.GREEN); //设置竖线的数量 //options.setCropGridColumnCount(2); //设置横线的数量 //options.setCropGridRowCount(1); UCrop.of(uri, destinationUri) .withAspectRatio(1, 1) .withMaxResultSize(1000, 1000) .withOptions(options) .start(this); }
Example 16
Source File: EasyPhotosActivity.java From imsdk-android with MIT License | 4 votes |
private void startCrop(Activity context, String source, Intent data) { BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(source, bitmapOptions); if (bitmapOptions.outWidth == -1 || bitmapOptions.outHeight == -1) { setResult(RESULT_OK, data); finish(); Log.e("EasyPhotos", "该类型不支持裁剪!"); return; } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HH:mm:ss", Locale.getDefault()); String suffix = source.substring(source.lastIndexOf(".")); String imageName = "IMG_CROP_%s" + suffix; String destinationFileName = String.format(imageName, dateFormat.format(new Date())); UCrop.Options options = new UCrop.Options(); //设置相关颜色 int statusBarColor = ContextCompat.getColor(this, R.color.easy_photos_status_bar); if (ColorUtils.isWhiteColor(statusBarColor)) { statusBarColor = Color.LTGRAY; } options.setStatusBarColor(statusBarColor); int barColor = ContextCompat.getColor(this, R.color.easy_photos_bar_primary); options.setToolbarColor(barColor); int widgetColor = ContextCompat.getColor(this, R.color.easy_photos_fg_primary); options.setToolbarWidgetColor(widgetColor); options.setActiveWidgetColor(Color.BLACK); //options.setLogoColor(Color.TRANSPARENT); //设置裁剪质量 options.setCompressionQuality(Setting.compressQuality); //是否圆形裁剪 options.setCircleDimmedLayer(Setting.isCircle); //设置网格相关 options.setShowCropFrame(Setting.isShowCropCropFrame); options.setShowCropGrid(Setting.isShowCropGrid); //是否自由裁剪 options.setFreeStyleCropEnabled(Setting.isFreeStyleCrop); //设置title options.setToolbarTitle(""); //隐藏底部控制栏 options.setHideBottomControls(Setting.isHideUCropControls); File cacheFile = new File(context.getCacheDir(), destinationFileName); UCrop.of(Uri.fromFile(new File(source)), Uri.fromFile(cacheFile)) .withAspectRatio(Setting.aspectRatio[0], Setting.aspectRatio[1]) .withOptions(options) .start(context); }
Example 17
Source File: PictureBaseActivity.java From PictureSelector with Apache License 2.0 | 4 votes |
/** * Set the crop style parameter * * @return */ private UCrop.Options basicOptions(ArrayList<CutInfo> list) { int toolbarColor = 0, statusColor = 0, titleColor = 0; boolean isChangeStatusBarFontColor; if (config.cropStyle != null) { if (config.cropStyle.cropTitleBarBackgroundColor != 0) { toolbarColor = config.cropStyle.cropTitleBarBackgroundColor; } if (config.cropStyle.cropStatusBarColorPrimaryDark != 0) { statusColor = config.cropStyle.cropStatusBarColorPrimaryDark; } if (config.cropStyle.cropTitleColor != 0) { titleColor = config.cropStyle.cropTitleColor; } isChangeStatusBarFontColor = config.cropStyle.isChangeStatusBarFontColor; } else { if (config.cropTitleBarBackgroundColor != 0) { toolbarColor = config.cropTitleBarBackgroundColor; } else { toolbarColor = AttrsUtils.getTypeValueColor(this, R.attr.picture_crop_toolbar_bg); } if (config.cropStatusBarColorPrimaryDark != 0) { statusColor = config.cropStatusBarColorPrimaryDark; } else { statusColor = AttrsUtils.getTypeValueColor(this, R.attr.picture_crop_status_color); } if (config.cropTitleColor != 0) { titleColor = config.cropTitleColor; } else { titleColor = AttrsUtils.getTypeValueColor(this, R.attr.picture_crop_title_color); } isChangeStatusBarFontColor = config.isChangeStatusBarFontColor; if (!isChangeStatusBarFontColor) { isChangeStatusBarFontColor = AttrsUtils.getTypeValueBoolean(this, R.attr.picture_statusFontColor); } } UCrop.Options options = config.uCropOptions == null ? new UCrop.Options() : config.uCropOptions; options.isOpenWhiteStatusBar(isChangeStatusBarFontColor); options.setToolbarColor(toolbarColor); options.setStatusBarColor(statusColor); options.setToolbarWidgetColor(titleColor); options.setCircleDimmedLayer(config.circleDimmedLayer); options.setDimmedLayerColor(config.circleDimmedColor); options.setDimmedLayerBorderColor(config.circleDimmedBorderColor); options.setCircleStrokeWidth(config.circleStrokeWidth); options.setShowCropFrame(config.showCropFrame); options.setDragFrameEnabled(config.isDragFrame); options.setShowCropGrid(config.showCropGrid); options.setScaleEnabled(config.scaleEnabled); options.setRotateEnabled(config.rotateEnabled); options.isMultipleSkipCrop(config.isMultipleSkipCrop); options.setHideBottomControls(config.hideBottomControls); options.setCompressionQuality(config.cropCompressQuality); options.setRenameCropFileName(config.renameCropFileName); options.isCamera(config.camera); options.setCutListData(list); options.isWithVideoImage(config.isWithVideoImage); options.setFreeStyleCropEnabled(config.freeStyleCropEnabled); options.setCropExitAnimation(config.windowAnimationStyle != null ? config.windowAnimationStyle.activityCropExitAnimation : 0); options.setNavBarColor(config.cropStyle != null ? config.cropStyle.cropNavBarColor : 0); options.withAspectRatio(config.aspect_ratio_x, config.aspect_ratio_y); options.isMultipleRecyclerAnimation(config.isMultipleRecyclerAnimation); if (config.cropWidth > 0 && config.cropHeight > 0) { options.withMaxResultSize(config.cropWidth, config.cropHeight); } return options; }
Example 18
Source File: RegisterActivity.java From Hify with MIT License | 4 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode==PICK_IMAGE){ if(resultCode==RESULT_OK){ imageUri=data.getData(); // start crop activity UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.PNG); options.setCompressionQuality(100); options.setShowCropGrid(true); UCrop.of(imageUri, Uri.fromFile(new File(getCacheDir(), "hify_user_profile_picture.png"))) .withAspectRatio(1, 1) .withOptions(options) .start(this); } } if (requestCode == UCrop.REQUEST_CROP) { if (resultCode == RESULT_OK) { imageUri = UCrop.getOutput(data); profile_image.setImageURI(imageUri); } else if (resultCode == UCrop.RESULT_ERROR) { Log.e("Error", "Crop error:" + UCrop.getError(data).getMessage()); } } }
Example 19
Source File: FragmentEditImage.java From iGap-Android with GNU Affero General Public License v3.0 | 4 votes |
private void goToCropPage(View v) { AndroidUtils.closeKeyboard(v); if (itemGalleryList.size() == 0){ return; } String newPath = "file://" + itemGalleryList.get(viewPager.getCurrentItem()).path; String fileNameWithOutExt = newPath.substring(newPath.lastIndexOf("/")); String extension = newPath.substring(newPath.lastIndexOf(".")); SAMPLE_CROPPED_IMAGE_NAME = fileNameWithOutExt.substring(0, fileNameWithOutExt.lastIndexOf(".")) + num + extension; num++; Uri uri = Uri.parse(newPath); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) { UCrop.Options options = new UCrop.Options(); options.setStatusBarColor(ContextCompat.getColor(G.context, R.color.black)); options.setToolbarColor(ContextCompat.getColor(G.context, R.color.black)); options.setCompressionQuality(80); options.setFreeStyleCropEnabled(true); UCrop.of(uri, Uri.fromFile(new File(G.DIR_IMAGES, SAMPLE_CROPPED_IMAGE_NAME))) .withOptions(options) .useSourceImageAspectRatio() .start(G.context, FragmentEditImage.this); } else { CropImage.activity(uri) .setGuidelines(CropImageView.Guidelines.ON) .setMinCropResultSize(120, 120) .setAutoZoomEnabled(false) .setInitialCropWindowPaddingRatio(.08f) // padding window from all .setBorderCornerLength(50) .setBorderCornerOffset(0) .setAllowCounterRotation(true) .setBorderCornerThickness(8.0f) .setShowCropOverlay(true) .setAspectRatio(1, 1) .setFixAspectRatio(false) .setBorderCornerColor(getResources().getColor(R.color.whit_background)) .setBackgroundColor(getResources().getColor(R.color.ou_background_crop)) .setScaleType(CropImageView.ScaleType.FIT_CENTER) .start(G.fragmentActivity, FragmentEditImage.this); } }
Example 20
Source File: PictureBaseActivity.java From PictureSelector with Apache License 2.0 | 2 votes |
/** * Set the crop style parameter * * @return */ private UCrop.Options basicOptions() { return basicOptions(null); }