本文整理汇总了Java中com.yalantis.ucrop.UCropActivity类的典型用法代码示例。如果您正苦于以下问题:Java UCropActivity类的具体用法?Java UCropActivity怎么用?Java UCropActivity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UCropActivity类属于com.yalantis.ucrop包,在下文中一共展示了UCropActivity类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startCropActivity
import com.yalantis.ucrop.UCropActivity; //导入依赖的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);
}
开发者ID:hss01248,项目名称:PhotoOut,代码行数:25,代码来源:MyTool.java
示例2: cropScannerForResult
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
/**
* 裁剪指定的路径-
* onActivityResult或者其它地方调用RxGalleryFinalApi.cropActivityForResult方法去刷新图库
* RxGalleryFinalApi.cropActivityForResult()
*/
public static void cropScannerForResult(Activity context, String outPPath, String inputPath) {
if (TextUtils.isEmpty(inputPath)) {
Logger.e("-裁剪没有图片-");
return;
}
Uri outUri = Uri.fromFile(new File(outPPath));
Uri inputUri = Uri.fromFile(new File(inputPath));
Intent intent = new Intent(context, UCropActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable(UCrop.EXTRA_OUTPUT_URI, outUri);
bundle.putParcelable(UCrop.EXTRA_INPUT_URI, inputUri);
cropImagePath = new File(outUri.getPath());
Logger.i("输出:" + outUri.getPath());
Logger.i("原图:" + inputUri.getPath());
intent.putExtras(bundle);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivityForResult(intent, -1);//无效
}
开发者ID:Loofer,项目名称:Watermark,代码行数:24,代码来源:RxGalleryFinalApi.java
示例3: startCropActivity
import com.yalantis.ucrop.UCropActivity; //导入依赖的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);
}
开发者ID:glassLake,项目名称:CropUtils,代码行数:23,代码来源:CropUtils.java
示例4: startCropActivity
import com.yalantis.ucrop.UCropActivity; //导入依赖的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);
}
开发者ID:hss01248,项目名称:PicCrop,代码行数:24,代码来源:PicCrop.java
示例5: cropAllowedGestures
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
/**
* Choose what set of gestures will be enabled on each tab - if any.
*/
public RxGalleryFinal cropAllowedGestures(@UCropActivity.GestureTypes int tabScale,
@UCropActivity.GestureTypes int tabRotate,
@UCropActivity.GestureTypes int tabAspectRatio) {
configuration.setAllowedGestures(new int[]{tabScale, tabRotate, tabAspectRatio});
return this;
}
开发者ID:Loofer,项目名称:Watermark,代码行数:10,代码来源:RxGalleryFinal.java
示例6: uCrop
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
private void uCrop(Uri fileUri) {
UCrop.Options options = new UCrop.Options();
options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.ROTATE, UCropActivity.ALL);
options.setCompressionQuality(100);
options.setHideBottomControls(true);
UCrop.of(fileUri, fileUri)
.withAspectRatio(8.6f, 5.4f)
.withMaxResultSize(3000, 3000)
.withOptions(options)
.start(OcrIdActivity.this);
}
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:12,代码来源:OcrIdActivity.java
示例7: startUCrop
import com.yalantis.ucrop.UCropActivity; //导入依赖的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;
}
开发者ID:linsir6,项目名称:TripBuyer,代码行数:35,代码来源:ReleaseOrderActivity.java
示例8: setAllowedGestures
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
public void setAllowedGestures(@UCropActivity.GestureTypes int[] gestures) {
this.gestures = gestures;
}
开发者ID:Loofer,项目名称:Watermark,代码行数:4,代码来源:Configuration.java
示例9: radioNext
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
/**
* 区分功能
*/
private void radioNext(MediaBean mediaBean) {
Logger.i("isCrop :" + mConfiguration.isCrop());
if (!mConfiguration.isCrop()) {
setPostMediaBean(mediaBean);
getActivity().finish();
} else {
//裁剪根据大家需求加上选择完图片后的回调
setPostMediaBean(mediaBean);
String originalPath = mediaBean.getOriginalPath();
File file = new File(originalPath);
Random random = new Random();
String outName = String.format(IMAGE_STORE_FILE_NAME, SimpleDateUtils.getNowTime() + "_" + random.nextInt(1024));
Logger.i("--->isCrop:" + mImageStoreCropDir);
Logger.i("--->mediaBean.getOriginalPath():" + mediaBean.getOriginalPath());
mCropPath = new File(mImageStoreCropDir, outName);
Uri outUri = Uri.fromFile(mCropPath);
if (!mImageStoreCropDir.exists()) {
mImageStoreCropDir.mkdirs();
}
if (!file.exists()) {
file.mkdirs();
}
Uri inputUri = Uri.fromFile(new File(mediaBean.getOriginalPath()));
Intent intent = new Intent(getContext(), UCropActivity.class);
// UCrop 参数 start
Bundle bundle = new Bundle();
bundle.putParcelable(UCrop.EXTRA_OUTPUT_URI, outUri);
bundle.putParcelable(UCrop.Options.EXTRA_ASPECT_RATIO_OPTIONS, mediaBean);
bundle.putInt(UCrop.Options.EXTRA_STATUS_BAR_COLOR, uCropStatusColor);
bundle.putInt(UCrop.Options.EXTRA_TOOL_BAR_COLOR, uCropToolbarColor);
bundle.putString(UCrop.Options.EXTRA_UCROP_TITLE_TEXT_TOOLBAR, uCropTitle);
bundle.putInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, uCropActivityWidgetColor);
bundle.putInt(UCrop.Options.EXTRA_UCROP_WIDGET_COLOR_TOOLBAR, uCropToolbarWidgetColor);
bundle.putBoolean(UCrop.Options.EXTRA_HIDE_BOTTOM_CONTROLS, mConfiguration.isHideBottomControls());
bundle.putIntArray(UCrop.Options.EXTRA_ALLOWED_GESTURES, mConfiguration.getAllowedGestures());
bundle.putInt(UCrop.Options.EXTRA_COMPRESSION_QUALITY, mConfiguration.getCompressionQuality());
bundle.putInt(UCrop.Options.EXTRA_MAX_BITMAP_SIZE, mConfiguration.getMaxBitmapSize());
bundle.putFloat(UCrop.Options.EXTRA_MAX_SCALE_MULTIPLIER, mConfiguration.getMaxScaleMultiplier());
bundle.putFloat(UCrop.EXTRA_ASPECT_RATIO_X, mConfiguration.getAspectRatioX());
bundle.putFloat(UCrop.EXTRA_ASPECT_RATIO_Y, mConfiguration.getAspectRatioY());
bundle.putInt(UCrop.EXTRA_MAX_SIZE_X, mConfiguration.getMaxResultWidth());
bundle.putInt(UCrop.EXTRA_MAX_SIZE_Y, mConfiguration.getMaxResultHeight());
bundle.putInt(UCrop.Options.EXTRA_ASPECT_RATIO_SELECTED_BY_DEFAULT, mConfiguration.getSelectedByDefault());
bundle.putBoolean(UCrop.Options.EXTRA_FREE_STYLE_CROP, mConfiguration.isFreestyleCropEnabled());
bundle.putParcelable(UCrop.EXTRA_INPUT_URI, inputUri);
// UCrop 参数 end
int bk = FileUtils.existImageDir(inputUri.getPath());
Logger.i("--->" + inputUri.getPath());
Logger.i("--->" + outUri.getPath());
ArrayList<AspectRatio> aspectRatioList = new ArrayList<>();
AspectRatio[] aspectRatios = mConfiguration.getAspectRatio();
if (aspectRatios != null) {
for (int i = 0; i < aspectRatios.length; i++) {
aspectRatioList.add(i, aspectRatios[i]);
Logger.i("自定义比例=>" + aspectRatioList.get(i).getAspectRatioX() + " " + aspectRatioList.get(i).getAspectRatioY());
}
}
// AspectRatio[]aspectRatios = mConfiguration.getAspectRatio();
bundle.putParcelableArrayList(UCrop.Options.EXTRA_ASPECT_RATIO_OPTIONS, aspectRatioList);//EXTRA_CONFIGURATION
intent.putExtras(bundle);
if (bk != -1) {
//裁剪
startActivityForResult(intent, CROP_IMAGE_REQUEST_CODE);
} else {
Logger.w("点击图片无效");
}
}
}
开发者ID:Loofer,项目名称:Watermark,代码行数:76,代码来源:MediaGridFragment.java
示例10: initUCrop
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
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);
}
开发者ID:vondear,项目名称:RxTools,代码行数:44,代码来源:ActivityRxPhoto.java
示例11: startCropActivity
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
public static void startCropActivity(Uri sourceUri, AppCompatActivity activityContext) {
final String SAMPLE_CROPPED_IMAGE_NAME = "SampleCropImage.jpeg";
Uri destinationUri = Uri.fromFile(new File(activityContext.getCacheDir(), SAMPLE_CROPPED_IMAGE_NAME));
UCrop.Options options = new UCrop.Options();
options.setCompressionFormat(Bitmap.CompressFormat.JPEG);
// options.setCompressionQuality(100);
options.setToolbarColor(activityContext.getResources().getColor(R.color.cyan900));
options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.ALL, UCropActivity.SCALE);
// this function takes the file from the source URI and saves in into the destination URI location.
UCrop.of(sourceUri, destinationUri)
.withOptions(options)
.withMaxResultSize(400,300)
.start(activityContext);
//.withMaxResultSize(500, 400)
//.withAspectRatio(16, 9)
}
开发者ID:SumeetMoray,项目名称:Nearby-Shops-Distributor-Android-app,代码行数:25,代码来源:ImageCropUtility.java
示例12: cropImage
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
@SuppressWarnings("ResultOfMethodCallIgnored")
public void cropImage(File srcFile) {
Log.i(TAG, "------------------ start crop file ---------------");
if (!(srcFile != null && srcFile.exists())) {
Log.i(TAG, "input file null or not exists ");
if (mCallback != null) {
mCallback.onCropperCallback(CropperResult.error_illegal_input_file, srcFile, null,null);
}
return;
}
File outFile = CommonUtils.generateExternalImageCacheFile(getContext(), ".jpg");
Log.i(TAG, "output file:" + outFile.getPath());
if (outFile.exists()) {
outFile.delete();
}
if (!outFile.getParentFile().exists()) {
outFile.getParentFile().mkdirs();
}
mSrcFile = srcFile;
mOutFile = outFile;
Uri uri = Uri.fromFile(srcFile);
if (uri.toString().contains("%")) {
String inputFileName = srcFile.getName();
String ext = inputFileName.substring(inputFileName.lastIndexOf("."));
mTempFile = CommonUtils.generateExternalImageCacheFile(getContext(), ext);
CommonUtils.copy(srcFile, mTempFile);
uri = Uri.fromFile(mTempFile);
Log.w(TAG, "use temp file:" + mTempFile.getPath());
}
UCrop.Options options=new UCrop.Options();
options.setShowCropGrid(false);
options.setHideBottomControls(true);
options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.ROTATE, UCropActivity.ALL);
options.setToolbarColor(ContextCompat.getColor(getContext(),android.R.color.black));
options.setToolbarTitle(" ");
if (mActivity != null) {
UCrop.of(uri, Uri.fromFile(outFile)).withMaxResultSize(mOutPutX,mOutPutY)
.withAspectRatio(mAspectX,mAspectY).withOptions(options).start(mActivity);
} else {
UCrop.of(uri, Uri.fromFile(outFile)).withMaxResultSize(mOutPutX,mOutPutY)
.withAspectRatio(mAspectX,mAspectY).withOptions(options).start(getContext(),mFragment);
}
}
开发者ID:zillachan,项目名称:LibZilla,代码行数:49,代码来源:ImageCropHelper.java
示例13: startCropActivity
import com.yalantis.ucrop.UCropActivity; //导入依赖的package包/类
void startCropActivity(Uri sourceUri, Context context) {
final String SAMPLE_CROPPED_IMAGE_NAME = "SampleCropImage.jpeg";
Uri destinationUri = Uri.fromFile(new File(getContext().getCacheDir(), SAMPLE_CROPPED_IMAGE_NAME));
UCrop.Options options = new UCrop.Options();
options.setFreeStyleCropEnabled(true);
// options.setCompressionFormat(Bitmap.CompressFormat.JPEG);
// options.setCompressionQuality(100);
options.setToolbarColor(ContextCompat.getColor(getContext(),R.color.blueGrey800));
options.setStatusBarColor(ContextCompat.getColor(getContext(),R.color.colorPrimary));
options.setAllowedGestures(UCropActivity.ALL, UCropActivity.ALL, UCropActivity.ALL);
// this function takes the file from the source URI and saves in into the destination URI location.
UCrop.of(sourceUri, destinationUri)
.withOptions(options)
.start(context,this);
//.withMaxResultSize(400,300)
//.withMaxResultSize(500, 400)
//.withAspectRatio(16, 9)
}
开发者ID:SumeetMoray,项目名称:Nearby-Shops-Distributor-Android-app,代码行数:29,代码来源:EditDeliveryFragment.java
注:本文中的com.yalantis.ucrop.UCropActivity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论