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


Java UCrop类代码示例

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


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

示例1: 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

示例2: onActivityResult

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == PICK_PIC_REQUEST) {
            List<String> photos = (List<String>) data.getSerializableExtra(GalleryActivity.PHOTOS);
            presenter.openCropper(photos.get(0));
        }
        if (requestCode == UCrop.REQUEST_CROP) {
            try {
                String filename = FNAME_PREFIX + System.currentTimeMillis();
                presenter.processPicture(
                        openFileOutput(filename, Context.MODE_PRIVATE), filename, UCrop.getOutput(data));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:19,代码来源:CameraActivity.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: cropScannerForResult

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

示例5: onActivityResult

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
        textView1.setText(R.string.identify_document);
        if (backTaked) {
            performOCRIFE(type, uri1, UCrop.getOutput(data));
            backTaked = false;
        } else {
            rectangleIfeFront.setVisibility(View.GONE);
            rectangleIfeBack.setVisibility(View.GONE);
            rectangleIneBack.setVisibility(View.GONE);
            uri1 = UCrop.getOutput(data);
            backTaked = true;
            if (type == Constants.IFEB || type == Constants.IFEC) {
                rectangleIfeBack.setVisibility(View.VISIBLE);
            } else if (type == Constants.IFED || type == Constants.IFEE) {
                rectangleIneBack.setVisibility(View.VISIBLE);
            }
        }
    } else {
        //final Throwable cropError = UCrop.getError(data);
    }
}
 
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:24,代码来源:OcrIdActivity.java

示例6: 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

示例7: 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

示例8: onActivityResult

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == REQUEST_SELECT_PICTURE) {
            final Uri selectedUri = data.getData();
            if (selectedUri != null) {
                startCropActivity(data.getData());
            } else {
                ToastUtils.showToast(UpdateUserInfoActivity.this,"类型不匹配");
            }
        } else if (requestCode == UCrop.REQUEST_CROP) {
            handleCropResult(data);
        }
    }
    if (resultCode == UCrop.RESULT_ERROR) {
        handleCropError(data);
    }
}
 
开发者ID:monsterLin,项目名称:Pigeon,代码行数:19,代码来源:UpdateUserInfoActivity.java

示例9: onActivityResult

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == REQUEST_SELECT_PICTURE) {
            final Uri selectedUri = data.getData();
            if (selectedUri != null) {
                startCropActivity(data.getData());
            } else {
                ToastUtils.showToast(EditFamilyActivity.this, "类型不匹配");
            }
        } else if (requestCode == UCrop.REQUEST_CROP) {
            handleCropResult(data);
        }
    }
    if (resultCode == UCrop.RESULT_ERROR) {
        handleCropError(data);
    }
}
 
开发者ID:monsterLin,项目名称:Pigeon,代码行数:19,代码来源:EditFamilyActivity.java

示例10: onActivityResult

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
            if (requestCode == REQUEST_LOAD_IMAGE && null != data) {
                final Uri selectedImage = data.getData();
                CropUtil.startCropActivity(MainActivity.this, selectedImage);
            } else if (requestCode == REQUEST_QRCODE && data != null) {
                dealQRCode(data);
            } else if (requestCode == REQUEST_IMAGE && data != null) {
                dealQRImage(data);
            } else if (requestCode == UCrop.REQUEST_CROP) {
                dealCropResult(data);
            }
        } else if (resultCode == UCrop.RESULT_ERROR) {
            handleCropError(data);
        }
//        super.onActivityResult(requestCode, resultCode, data);
    }
 
开发者ID:hkq325800,项目名称:YellowNote,代码行数:19,代码来源:MainActivity.java

示例11: dealCropResult

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
private void dealCropResult(@NonNull Intent result) {
        //得到结果的uri
        final Uri resultUri = UCrop.getOutput(result);
        if (resultUri != null) {
            ThreadPool.getInstance().execute(new Runnable() {
                @Override
                public void run() {
                    dealPicFromSelect(resultUri);
                }
            });
            //传送到结果界面预览
//            ResultActivity.startWithUri(MainActivity.this, resultUri);
        } else {
            Trace.show(mContext, "无法取回剪切过的图片");
        }
    }
 
开发者ID:hkq325800,项目名称:YellowNote,代码行数:17,代码来源:MainActivity.java

示例12: basisConfig

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
/**
 * In most cases you need only to set crop aspect ration and max size for resulting image.
 *
 * @param uCrop - ucrop builder instance
 * @return - ucrop builder instance
 */
private static UCrop basisConfig(@NonNull UCrop uCrop, float ratioX, float ratioY) {
    switch (aspectType) {
        case ASPEC_TYPE_ORIGIN:
            uCrop = uCrop.useSourceImageAspectRatio();
            break;
        case ASPEC_TYPE_SQUARE:
            uCrop = uCrop.withAspectRatio(1, 1);
            break;
        case ASPEC_TYPE_DYNAMIC:
            // do nothing
            break;
        case ASPEC_TYPE_XY:
            //xy的比例
            if (ratioX > 0 && ratioY > 0) {
                uCrop = uCrop.withAspectRatio(ratioX, ratioY);
            }
            break;
    }

    return uCrop;
}
 
开发者ID:hkq325800,项目名称:YellowNote,代码行数:28,代码来源:CropUtil.java

示例13: onActivityResultToCrop

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
public void onActivityResultToCrop(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == REQUEST_SELECT_PICTURE) {
            final Uri selectedUri = data.getData();
            if (selectedUri != null) {
                startCropActivity(data.getData());
            } else {
                Toast.makeText(mActivity,
                        R.string.toast_cannot_retrieve_selected_image,
                        Toast.LENGTH_SHORT).show();
            }
        } else if (requestCode == UCrop.REQUEST_CROP) {
            handleCropResult(data);
        }
    }
    if (resultCode == UCrop.RESULT_ERROR) {
        handleCropError(data);
    }
}
 
开发者ID:drakeet,项目名称:Lunei,代码行数:20,代码来源:TakePictureHelper.java

示例14: handleResult

import com.yalantis.ucrop.UCrop; //导入依赖的package包/类
/**
 * 注意,调用时data为null的判断
 *
 * @param context
 * @param cropHandler
 * @param requestCode
 * @param resultCode
 * @param data
 */
public static void handleResult(Activity context, CropHandler cropHandler, int requestCode, int resultCode, Intent data) {

    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == REQUEST_SELECT_PICTURE) {//第一次,选择图片后返回
            final Uri selectedUri = data.getData();
            if (selectedUri != null) {
                startCropActivity(context, data.getData());
            } else {
                Toast.makeText(context, "Cannot retrieve selected image", Toast.LENGTH_SHORT).show();
            }
        } else if (requestCode == UCrop.REQUEST_CROP) {//第二次返回,图片已经剪切好

            Uri finalUri = UCrop.getOutput(data);
            cropHandler.handleCropResult(finalUri,config.tag);

        } else if (requestCode == REQUEST_CAMERA) {//第一次,拍照后返回,因为设置了MediaStore.EXTRA_OUTPUT,所以data为null,数据直接就在uri中
            startCropActivity(context, uri);
        }
    }
    if (resultCode == UCrop.RESULT_ERROR) {
        cropHandler.handleCropError(data);
    }

}
 
开发者ID:glassLake,项目名称:CropUtils,代码行数:34,代码来源:CropUtils.java

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


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