2013-11-27 23 views
0

我正在使用android的作物功能。我的問題是每次拖動廣場的左側/右側,底部都會出現。它保留了正方形的比例。更改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

我發現這個簡單的解決方案:

intent.putExtra("aspectX", 0); 
intent.putExtra("aspectY", 0);