本文整理汇总了Java中com.yalantis.ucrop.UCrop.withOptions方法的典型用法代码示例。如果您正苦于以下问题:Java UCrop.withOptions方法的具体用法?Java UCrop.withOptions怎么用?Java UCrop.withOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.yalantis.ucrop.UCrop
的用法示例。
在下文中一共展示了UCrop.withOptions方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
public static void startCropActivity(Activity context, Uri sourceUri,BasePhotoBuilder builder) {
CropConfig config = buildCropConfig(builder);
Uri mDestinationUri = buildUri(builder,false);
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);
}
示例2: advancedConfig
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private UCrop advancedConfig(@NonNull UCrop uCrop) {
UCrop.Options options = new UCrop.Options();
options.setCompressionFormat(Bitmap.CompressFormat.JPEG);
options.setCompressionQuality(50);
// options.setCompressionQuality(DEFAULT_COMPRESS_QUALITY);
options.setFreeStyleCropEnabled(false);
options.setAspectRatioOptions(1,
new AspectRatio("1:2", 1, 2),
new AspectRatio("3:4", 3, 4),
new AspectRatio("DEFAULT", CropImageView.DEFAULT_ASPECT_RATIO, CropImageView.DEFAULT_ASPECT_RATIO),
new AspectRatio("16:9", 16, 9),
new AspectRatio("1:1", 1, 1));
// options.setImageToCropBoundsAnimDuration(CROP_BOUNDS_ANIMATION_DURATION);
options.setShowCropGrid(false);
options.setMaxScaleMultiplier(10.0f);
return uCrop.withOptions(options);
}
示例3: advancedConfig
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private UCrop advancedConfig(@NonNull UCrop uCrop) {
UCrop.Options options = new UCrop.Options();
options.setCompressionFormat(Bitmap.CompressFormat.JPEG);
options.setCompressionQuality(50);
// options.setCompressionQuality(DEFAULT_COMPRESS_QUALITY);
options.setFreeStyleCropEnabled(false);
options.setAspectRatioOptions(1,
new AspectRatio("1:2", 1, 2),
new AspectRatio("3:4", 3, 4),
new AspectRatio("DEFAULT", CropImageView.DEFAULT_ASPECT_RATIO, CropImageView.DEFAULT_ASPECT_RATIO),
new AspectRatio("16:9", 16, 9),
new AspectRatio("1:1", 1, 1));
// options.setImageToCropBoundsAnimDuration(CROP_BOUNDS_ANIMATION_DURATION);
options.setShowCropGrid(false);
options.setMaxScaleMultiplier(10.0f);
return uCrop.withOptions(options);
}
示例4: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
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);
}
示例5: startCropping
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
/**
* Start the cropping activity via Yalantis UCrop
* @param sourceUri Source URI to crop
* @param destinationUri Destination URI
*/
public void startCropping(Uri sourceUri, Uri destinationUri){
//Build options
options = optionsAndFlags.cropOptions;
if(options == null) {
options = CameraMediaUtilities.buildUCropOptions();
}
try {
UCrop cropping = UCrop.of(sourceUri, destinationUri);
//cropping.withMaxResultSize(maxWidth, maxHeight);
if(options != null){
cropping.withOptions(options);
}
cropping.start(activity, TAG_CROP_PHOTO);
} catch (Exception e){
e.printStackTrace();
listener.onTaskComplete("An error occurred while processing your photo", TAG_CROP_ERROR);
}
}
示例6: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
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);
}
示例7: onActivityResult
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (resultCode) {
case Activity.RESULT_CANCELED:
listener.onCropCancel();
break;
case UCrop.RESULT_ERROR:
if (data != null) {
Throwable cropError = UCrop.getError(data);
if (cropError != null) {
listener.onCropError(cropError.getMessage());
} else {
listener.onCropError("裁剪出现未知错误");
}
} else {
listener.onCropError("获取相册图片出现错误");
}
break;
case Activity.RESULT_OK:
switch (requestCode) {
case TYPE_CAMERA:
notifyImageToCamera(listener.getSimpleActivity(), imagePath);
UCrop of = UCrop.of(imagePath, Uri.fromFile(getDiskCacheDir()));
// of.withAspectRatio(8,5);
UCrop.Options options = new UCrop.Options();
options.setAspectRatioOptions(0, new AspectRatio("8:5", 8, 5));
of.withOptions(options);
of.start(listener.getSimpleActivity());
break;
case UCrop.REQUEST_CROP:
listener.onCropSuccess(UCrop.getOutput(data));
break;
}
break;
}
}
示例8: startUCrop
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
public static String startUCrop(Activity activity, String sourceFilePath,
int requestCode, float aspectRatioX, float aspectRatioY) {
Uri sourceUri = Uri.fromFile(new File(sourceFilePath));
File outDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
if (!outDir.exists()) {
outDir.mkdirs();
}
File outFile = new File(outDir, System.currentTimeMillis() + ".jpg");
//裁剪后图片的绝对路径
String cameraScalePath = outFile.getAbsolutePath();
Uri destinationUri = Uri.fromFile(outFile);
//初始化,第一个参数:需要裁剪的图片;第二个参数:裁剪后图片
UCrop uCrop = UCrop.of(sourceUri, destinationUri);
//初始化UCrop配置
UCrop.Options options = new UCrop.Options();
//设置裁剪图片可操作的手势
options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.ROTATE, UCropActivity.ALL);
//是否隐藏底部容器,默认显示
options.setHideBottomControls(true);
//设置toolbar颜色
options.setToolbarColor(ActivityCompat.getColor(activity, R.color.colorPrimary));
//设置状态栏颜色
options.setStatusBarColor(ActivityCompat.getColor(activity, R.color.colorPrimary));
//是否能调整裁剪框
options.setFreeStyleCropEnabled(true);
//UCrop配置
uCrop.withOptions(options);
//设置裁剪图片的宽高比,比如16:9
uCrop.withAspectRatio(aspectRatioX, aspectRatioY);
//uCrop.useSourceImageAspectRatio();
//跳转裁剪页面
uCrop.start(activity, requestCode);
return cameraScalePath;
}
示例9: startForImageCrop
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
public static void startForImageCrop(final Provider provider, final Uri uri, int maxOutputWidth, int maxOutputHeight, final OnError onError, final @Nullable UCrop.Options options) {
try {
final UCrop.Options cropOptions = options != null
? options
: new UCrop.Options();
// Force JPEG format compression now while working out filename strategy.
cropOptions.setCompressionFormat(Bitmap.CompressFormat.JPEG);
final Context context = provider.getContext();
//TODO: replace this with directly using a FileProvider URI once UCrop can handle it.
final Uri destUri = Uri.fromFile(provider.getImageFile());
final UCrop uCrop = UCrop.of(uri, destUri);
uCrop.withOptions(cropOptions);
uCrop.withMaxResultSize(maxOutputWidth, maxOutputHeight);
final Intent intent = uCrop.getIntent(context);
grantWriteAccessToURI(context, intent, destUri);
startFor(provider, intent, RequestType.CROP.getCode());
} catch (final IOException e) {
onError.onError(e);
}
}
示例10: advancedConfig
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
/**
* Sometimes you want to adjust more options, it's done via {@link com.yalantis.ucrop.UCrop.Options} class.
*
* @param uCrop - ucrop builder instance
* @return - ucrop builder instance
*/
private static UCrop advancedConfig(@NonNull UCrop uCrop) {
UCrop.Options options = new UCrop.Options();
options.setCompressionFormat(PNGorJPEG ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG);
//jpeg quality 90
options.setCompressionQuality(compressQuality);//mSeekBarQuality.getProgress()
//isHideBottomControls
options.setHideBottomControls(isHideBottomControls);//mCheckBoxHideBottomControls.isChecked()
//isFreeStyle
options.setFreeStyleCropEnabled(isFreeStyleCropEnabled);//mCheckBoxFreeStyleCrop.isChecked()
/*
If you want to configure how gestures work for all UCropActivity tabs
options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.ROTATE, UCropActivity.ALL);
* */
/*
This sets max size for bitmap that will be decoded from source Uri.
More size - more memory allocation, default implementation uses screen diagonal.
options.setMaxBitmapSize(640);
* */
// Tune everything (ノ◕ヮ◕)ノ*:・゚✧
options.setMaxScaleMultiplier(5);
options.setImageToCropBoundsAnimDuration(666);
// options.setDimmedLayerColor(Color.CYAN);
options.setCircleDimmedLayer(isCircleDimmedLayer);//是否圆形
options.setShowCropFrame(true);//外围边线
//栅格线
// options.setCropGridStrokeWidth(20);
// options.setCropGridColor(Color.GREEN);
options.setCropGridColumnCount(0);
options.setCropGridRowCount(0);
//工具栏
// options.setToolbarCropDrawable(R.drawable.your_crop_icon);
// options.setToolbarCancelDrawable(R.drawable.your_cancel_icon);
/*
// Color palette
options.setToolbarColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setStatusBarColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setActiveWidgetColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setToolbarWidgetColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setRootViewBackgroundColor(ContextCompat.getColor(this, R.color.your_color_res));
// Aspect ratio options
options.setAspectRatioOptions(1,
new AspectRatio("WOW", 1, 2),
new AspectRatio("MUCH", 3, 4),
new AspectRatio("RATIO", CropImageView.DEFAULT_ASPECT_RATIO, CropImageView.DEFAULT_ASPECT_RATIO),
new AspectRatio("SO", 16, 9),
new AspectRatio("ASPECT", 1, 1));
*/
return uCrop.withOptions(options);
}
示例11: advancedConfig
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private UCrop advancedConfig(@NonNull UCrop uCrop) {
UCrop.Options options = new UCrop.Options();
options.setShowCropGrid(false);
return uCrop.withOptions(options);
}