本文整理汇总了Java中com.yalantis.ucrop.UCrop.of方法的典型用法代码示例。如果您正苦于以下问题:Java UCrop.of方法的具体用法?Java UCrop.of怎么用?Java UCrop.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.yalantis.ucrop.UCrop
的用法示例。
在下文中一共展示了UCrop.of方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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);
}
}
示例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.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);
}
示例5: 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;
}
}
示例6: 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;
}
示例7: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
/**
* @param activity
* @param uri // * @param compressionSet mRadioGroupCompressionSettings.getCheckedRadioButtonId()
* // * @param aspectChecked mRadioGroupAspectRatio.getCheckedRadioButtonId()
*/
public static void startCropActivity(Activity activity, @NonNull Uri uri) {
String destinationFileName = SAMPLE_CROPPED_IMAGE_NAME;
if (PNGorJPEG)
destinationFileName += ".png";
else
destinationFileName += ".jpg";
UCrop uCrop = UCrop.of(uri, Uri.fromFile(new File(cacheDir, destinationFileName)));
uCrop = basisConfig(uCrop, 1, 1);
uCrop = advancedConfig(uCrop);
uCrop.start(activity);
}
示例8: 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);
}
}
示例9: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private void startCropActivity(@NonNull Uri uri) {
UCrop uCrop = UCrop.of(uri, mDestinationUri);
uCrop = basisConfig(uCrop);
uCrop = advancedConfig(uCrop);
if (mFragment == null) {
uCrop.start(mActivity);
} else {
uCrop.start(mActivity, mFragment);
}
}
示例10: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private void startCropActivity(@NonNull Uri uri) {
UCrop uCrop = UCrop.of(uri, Uri.fromFile(tempOutputFile));
uCrop = advancedConfig(uCrop);
uCrop.start(ChangeProfileActivity.this);
}
示例11: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private void startCropActivity(@NonNull Uri uri) {
UCrop uCrop = UCrop.of(uri, Uri.fromFile(tempOutputFile));
uCrop = advancedConfig(uCrop);
uCrop.start(MessageActivity.this);
}
示例12: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private void startCropActivity(@NonNull Uri uri) {
UCrop uCrop = UCrop.of(uri, Uri.fromFile(tempOutputFile));
uCrop = advancedConfig(uCrop);
uCrop.start(CreateGroupDescActivity.this);
}
示例13: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private void startCropActivity(@NonNull Uri uri) {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s = sdf.format(d);
String destinationFileName = s + ".jpg";
UCrop uCrop = UCrop.of(uri, Uri.fromFile(new File(getCacheDir(), destinationFileName)));
uCrop = uCrop.useSourceImageAspectRatio();
uCrop.start(UpdateUserInfoActivity.this);
}
示例14: startCropActivity
import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
private void startCropActivity(@NonNull Uri uri) {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s = sdf.format(d);
String destinationFileName = s + ".jpg";
UCrop uCrop = UCrop.of(uri, Uri.fromFile(new File(getCacheDir(), destinationFileName)));
uCrop = uCrop.useSourceImageAspectRatio();
uCrop.start(EditFamilyActivity.this);
}