1. 程式人生 > >Android com.android.camera.action.CROP 裁剪圖片的問題

Android com.android.camera.action.CROP 裁剪圖片的問題

大部分如果遇到這個方法 設定引數 然後裁切都很正常 但是在單張圖片裁切小圖的時候 當裁切的圖片尺寸別預設的大小小的時候會有黑邊

怎麼解決呢?

Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(Uri.fromFile(new File(imagePath)), "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", aspectX);
intent.putExtra("aspectY", aspectY);
intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("return-data", false);intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); startActivityForResult(intent, ImageSelector.IMAGE_CROP_CODE);
這些引數當裁切小圖的時候會有黑邊,只要加上這兩個引數就可以了:
intent .putExtra("scale", true
);//黑邊 intent .putExtra("scaleUpIfNeeded", true);//黑邊