如何在Android中限制裁剪的图像大小?

如何在Android中限制裁剪的图像大小?,android,crop,resize-crop,Android,Crop,Resize Crop,我需要设置最大和最小x,y尺寸和矩形裁剪面积 可能吗? 如果是,怎么做 裁剪方法在正常使用下效果很好,但不是定制的,它只是裁剪,我不能限制裁剪的大小 如何设置最小和最大裁剪尺寸?我使用的方法是: private void doCrop() { final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>(); Intent intent = new Intent("com.andr

我需要设置最大和最小x,y尺寸和矩形裁剪面积

可能吗? 如果是,怎么做

裁剪方法在正常使用下效果很好,但不是定制的,它只是裁剪,我不能限制裁剪的大小

如何设置最小和最大裁剪尺寸?我使用的方法是:

private void doCrop() {
    final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>();

    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setType("image/*");

    List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, 0);

    int size = list.size();

    if (size == 0) {
        Toast.makeText(this, getApplicationContext().getString(R.string.crop_unavailable), Toast.LENGTH_SHORT).show();
        // return
    } else {
        intent.setData(mImageCaptureUri);
        int y = 200;
        if(lastSelect == 1 || lastSelect == 2 || lastSelect == 3 || lastSelect == 4){
            y = (int) (200 * 0.5697329376854599);
        }
        intent.putExtra("outputX", 200);
        intent.putExtra("outputY", y);
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 0.5697329376854599);
        intent.putExtra("scale", true);
        intent.putExtra("return-data", true);

        if (size == 1) {
            Intent i = new Intent(intent);
            ResolveInfo res = list.get(0);

            i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));

            startActivityForResult(i, CROP_FROM_CAMERA);
        } else {
            for (ResolveInfo res: list) {
                final CropOption co = new CropOption();

                co.title = getPackageManager().getApplicationLabel(res.activityInfo.applicationInfo);
                co.icon = getPackageManager().getApplicationIcon(res.activityInfo.applicationInfo);
                co.appIntent = new Intent(intent);

                co.appIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));

                cropOptions.add(co);
            }

            CropOptionAdapter adapter = new CropOptionAdapter(getApplicationContext(), cropOptions);

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(getApplicationContext().getString(R.string.select_crop_app));
            builder.setAdapter(adapter, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int item) {
                    startActivityForResult(cropOptions.get(item).appIntent, CROP_FROM_CAMERA);
                }
            });

            builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {

                    if (mImageCaptureUri != null) {
                        getContentResolver().delete(mImageCaptureUri, null, null);
                        mImageCaptureUri = null;
                    }
                }
            });

            AlertDialog alert = builder.create();

            alert.show();
        }
    }
}
private void doCrop(){
最终ArrayList cropOptions=新ArrayList();
Intent Intent=newintent(“com.android.camera.action.CROP”);
intent.setType(“image/*”);
List List=getPackageManager().queryInputActivities(intent,0);
int size=list.size();
如果(大小==0){
Toast.makeText(这个,getApplicationContext().getString(R.string.crop_不可用),Toast.LENGTH_SHORT.show();
//返回
}否则{
intent.setData(mImageCaptureUri);
int y=200;
如果(lastSelect==1 | | lastSelect==2 | | lastSelect==3 | | lastSelect==4){
y=(整数)(200*0.5697329376854599);
}
意向。额外(“输出”,200);
意向。额外(“输出”,y);
intent.putExtra(“aspectX”,1);
intent.putExtra(“aspectY”,0.5697329376854599);
意图。putExtra(“比例”,真实);
intent.putExtra(“返回数据”,true);
如果(大小==1){
意向i=新意向(意向);
ResolveInfo res=list.get(0);
i、 setComponent(新组件名(res.activityInfo.packageName,res.activityInfo.name));
startActivityForResult(i,从摄像头裁剪);
}否则{
用于(ResolveInfo res:list){
最终CropOption co=新CropOption();
co.title=getPackageManager().getApplicationLabel(res.activityInfo.applicationInfo);
co.icon=getPackageManager().getApplicationInfo(res.activityInfo.applicationInfo);
co.appIntent=新意向(意向);
co.appIntent.setComponent(新组件名称(res.activityInfo.packageName,res.activityInfo.name));
添加(co);
}
CropOptionAdapter=新的CropOptionAdapter(getApplicationContext(),cropOptions);
AlertDialog.Builder=新建AlertDialog.Builder(此);
setTitle(getApplicationContext().getString(R.string.select_crop_app));
setAdapter(适配器,新的DialogInterface.OnClickListener(){
@凌驾
公共void onClick(对话框接口对话框,int项){
startActivityForResult(cropOptions.get(item).appIntent,从摄像头裁剪);
}
});
builder.setOnCancelListener(新的DialogInterface.OnCancelListener(){
@凌驾
public void onCancel(对话框接口对话框){
if(mImageCaptureUri!=null){
getContentResolver().delete(mImageCaptureUri,null,null);
mImageCaptureUri=null;
}
}
});
AlertDialog alert=builder.create();
alert.show();
}
}
}

我认为这可能有帮助不,没有,我从设备使用裁剪应用程序,并将结果传递给OnAcrivityResult,我需要在SD Card上选择、裁剪并保存裁剪后的图像我认为这可能有帮助不,没有,我从设备使用裁剪应用程序,并将结果传递给OnAcrivityResult,我需要选择,裁剪,并将裁剪后的图像保存在SD卡上