我正在使用android的裁剪功能。我的问题是每次我拖动广场的左/右侧,底部跟随。它保留了方形的比例。
任何解决方案如何改变盒子的比例,例如我想裁剪矩形而不是方形。
这是我的代码
private void doCrop() {
try {
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setDataAndType(mImageCaptureUri, "image/*");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);
cropIntent.putExtra("return-data", true);
startActivityForResult(cropIntent, CROP_FROM_CAMERA);
}
catch(ActivityNotFoundException anfe)
{
String errorMessage = "your device doesn't support the crop action!";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == CROP_FROM_CAMERA && resultCode == RESULT_OK)
{
Bundle extras = data.getExtras();
Bitmap thePic = extras.getParcelable("data");
ImageView picView = (ImageView)findViewById(R.id.imgView);
picView.setScaleType(ScaleType.FIT_XY);
picView.setImageBitmap(thePic);
}
}
答案 0 :(得分:0)
我找到了简单的解决方案:
intent.putExtra("aspectX", 0);
intent.putExtra("aspectY", 0);