当前位置: 首页>>代码示例>>Java>>正文


Java UCrop.Options方法代码示例

本文整理汇总了Java中com.yalantis.ucrop.UCrop.Options方法的典型用法代码示例。如果您正苦于以下问题:Java UCrop.Options方法的具体用法?Java UCrop.Options怎么用?Java UCrop.Options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.yalantis.ucrop.UCrop的用法示例。


在下文中一共展示了UCrop.Options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildUCropOptions

import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
public static UCrop.Options buildUCropOptions(@NonNull final Context context,
                                               int frameColor, int statusBarColor,
                                               int toolbarColor){
    UCrop.Options options = new UCrop.Options();
    options.useSourceImageAspectRatio();
    //https://github.com/Yalantis/uCrop/issues/173
    //options.withAspectRatio(1, 1);
    if(frameColor != -100){
        options.setCropFrameColor(ContextCompat.getColor(context, frameColor));
    }
    if(statusBarColor != -100){
        options.setStatusBarColor(ContextCompat.getColor(context, statusBarColor));
    }
    if(toolbarColor != -100){
        options.setToolbarColor(ContextCompat.getColor(context, toolbarColor));
    }

    return options;
}
 
开发者ID:PGMacDesign,项目名称:PGMacTips,代码行数:20,代码来源:CameraMediaUtilities.java

示例2: onStartCrop

import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BoxingUcrop.java

示例3: 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);
}
 
开发者ID:hss01248,项目名称:PhotoOut,代码行数:25,代码来源:MyTool.java

示例4: 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);
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:19,代码来源:ChangeProfileActivity.java

示例5: 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);
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:19,代码来源:MessageActivity.java

示例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);
 }
 
开发者ID:hss01248,项目名称:PicCrop,代码行数:24,代码来源:PicCrop.java

示例7: CameraUtilityOptionsAndFlags

import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
/**
 * Constructor
 * @param maxVideoRecordingTime If recording a video, max recording time. (IN SECONDS! NOT
 *                              IN MILLISECONDS!)
 * @param nameOfFile The name of the file
 * @param pathToFile The path to the file
 * @param shouldUploadPhoto Boolean, should the photo be uploaded or not
 * @param shouldDeletePhotoAfter Boolean, should the photo be deleted or not afterwards
 * @param useDefaultToFrontFacingCamera Boolean, should the camera default to the front
 *                                      facing camera or not
 * @param alertDialog Alert dialog. If none selected, default one (PGMacCustom SVG)
 *                    will be selected
 * @param webImageUrlToDownload The web imageURL String if included
 * @param videoExtension The video extension format {@link SupportedVideoFileExtensions}
 * @param photoExtension The photo extension format {@link SupportedPhotoFileExtensions}
 */
public CameraUtilityOptionsAndFlags(Integer maxVideoRecordingTime, String nameOfFile,
                                    String pathToFile, boolean shouldCropPhoto,
                                    boolean shouldUploadPhoto,
                                    boolean shouldDeletePhotoAfter,
                                    boolean useDefaultToFrontFacingCamera,
                                    AlertDialog alertDialog, String webImageUrlToDownload,
                                    SupportedVideoFileExtensions videoExtension,
                                    SupportedPhotoFileExtensions photoExtension,
                                    UCrop.Options cropOptions,
                                    String fileProviderStr) {
    this.videoExtension = videoExtension;
    this.photoExtension = photoExtension;
    this.maxVideoRecordingTime = maxVideoRecordingTime;
    this.nameOfFile = nameOfFile;
    this.pathToFile = pathToFile;
    this.shouldUploadPhoto = shouldUploadPhoto;
    this.shouldCropPhoto = shouldCropPhoto;
    this.shouldDeletePhotoAfter = shouldDeletePhotoAfter;
    this.useDefaultToFrontFacingCamera = useDefaultToFrontFacingCamera;
    this.alertDialog = alertDialog;
    this.webImageUrlToDownload = webImageUrlToDownload;
    this.cropOptions = cropOptions;
    this.fileProviderStr = fileProviderStr;
}
 
开发者ID:PGMacDesign,项目名称:PGMacTips,代码行数:41,代码来源:CameraMediaUtilities.java

示例8: openCropper

import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
@Override
public void openCropper(String image) {
    String filename = FNAME_PREFIX + System.currentTimeMillis();
    UCrop.Options options = new UCrop.Options();
    options.setToolbarTitle(getString(R.string.title_cropper));
    options.setCompressionQuality(PrefUtils.getImageQualityPref(getApplicationContext()));
    options.setCompressionFormat(PrefUtils.getImageBitmapCompressFormatPref(getApplicationContext()));
    options.setHideBottomControls(true);
    options.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
    options.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
    UCrop.of(Uri.fromFile(new File(image)), Uri.fromFile(new File(getFilesDir(), filename)))
            .withOptions(options)
            .withAspectRatio(1, 1)
            .start(this);
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:16,代码来源:CameraActivity.java

示例9: 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;
        }
    }
 
开发者ID:Loofer,项目名称:Watermark,代码行数:37,代码来源:SimpleRxGalleryFinal.java

示例10: uCrop

import com.yalantis.ucrop.UCrop; //导入方法依赖的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

示例11: getUCropOptions

import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
/**
* 配置图片裁剪工具
*/
private UCrop.Options getUCropOptions() {
    UCrop.Options options = new UCrop.Options();
    //设置工具栏颜色
    options.setToolbarColor(getResources().getColor(R.color.brands_color));
    //设置工具类标题
    options.setToolbarTitle(getResources().getString(R.string.crop_avatar));
    options.setActiveWidgetColor(getResources().getColor(R.color.brands_color));
    options.setStatusBarColor(getResources().getColor(R.color.brands_color));
    options.setLogoColor(getResources().getColor(R.color.brands_color));
    return options;
}
 
开发者ID:organizationAllink,项目名称:wzyx-android-user,代码行数:15,代码来源:AccountSettingActivity.java

示例12: 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;
}
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:35,代码来源:ReleaseOrderActivity.java

示例13: 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);
    }
}
 
开发者ID:mrkcsc,项目名称:android-media-picker,代码行数:30,代码来源:MediaPicker.java

示例14: cropRawPhoto

import com.yalantis.ucrop.UCrop; //导入方法依赖的package包/类
/**
 * 使用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);

    // 设置源uri及目标uri
    UCrop.of(uri, Uri.fromFile(new File(mFilepath, System.currentTimeMillis() + ".jpg")))
            // 长宽比
            .withAspectRatio(1, 1)
            // 图片大小
            .withMaxResultSize(200, 200)
            // 配置参数
            .withOptions(options)
            .start(this);
}
 
开发者ID:sdwfqin,项目名称:AndroidSamples,代码行数:33,代码来源:PictureActivity.java

示例15: 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);
    }
 
开发者ID:hkq325800,项目名称:YellowNote,代码行数:67,代码来源:CropUtil.java


注:本文中的com.yalantis.ucrop.UCrop.Options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。