0
A
回答
0
我想你在找什麼是裁剪圖像。
可以實現與Android默認裁剪功能:
private void performCrop(Uri picUri) {
try {
Intent cropIntent = new Intent("com.android.camera.action.CROP");
// indicate image type and Uri
cropIntent.setDataAndType(picUri, "image/*");
// set crop properties
cropIntent.putExtra("crop", "true");
// indicate aspect of desired crop
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
// indicate output X and Y
cropIntent.putExtra("outputX", 128);
cropIntent.putExtra("outputY", 128);
// retrieve data on return
cropIntent.putExtra("return-data", true);
// start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, PIC_CROP);
}
// respond to users whose devices do not support the crop action
catch (ActivityNotFoundException anfe) {
// display an error message
String errorMessage = "Whoops - your device doesn't support the crop action!";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
恆聲明:您的活動
final int PIC_CROP = 1;
覆蓋onActivity結果的方法,令狀下面的代碼:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PIC_CROP) {
if (data != null) {
// get the returned data
Bundle extras = data.getExtras();
// get the cropped bitmap
Bitmap selectedBitmap = extras.getParcelable("data");
imgView.setImageBitmap(selectedBitmap);
}
}
}
相關問題
- 1. 圖像縮放調整大小IMAGEVIEW android
- 2. 如何在Android中通過放大和縮小拖動圖像並拖動
- 3. Android:高質量圖像大小調整/縮放
- 4. Android:調整圖像大小並縮放一部分
- 5. RMagick:爲縮略圖縮放和調整圖像大小
- 6. 調整大小/縮放位圖後圖像質量不佳
- 7. 放大/縮小AbsoluteLayout上的圖像Android
- 8. 放大和縮小android中的圖像
- 9. 放大和縮小android中的圖像
- 10. 如何在android中放大,縮小,拖放和旋轉圖像視圖?
- 11. 多個圖像大小vs瀏覽器圖像大小調整/縮放
- 12. 調整MKAnnotationView圖像當地圖放大和縮小時?
- 13. 調整大小svg圖像放入html5
- 14. 動力學JS拖放,調整大小和旋轉圖像
- 15. HTML5畫布拖放,調整圖像大小
- 16. 如何使用jQuery在圖像上拖放和調整大小?
- 17. 調整大小/縮放圖像會導致失真
- 18. 如何通過拖動邊緣來移動和縮放圖像?
- 19. 調整圖像大小後放大圖像內的圖像
- 20. jQuery UI:通過CSS縮放內容時調整對象大小
- 21. 捏放大圖像和縮小圖像
- 22. 拖放大小拖放區
- 23. 在iframe中自動縮放(調整大小)圖像
- 24. 如何在縮放後在imageView中調整圖像大小?
- 25. jQuery的,縮放和調整圖像大小
- 26. 在窗口大小調整時縮放SVG背景圖像div
- 27. UIButton圖像調整大小/縮放以適合
- 28. 如何修復調整大小和縮放背景圖像?
- 29. 縮放比,沒有jQuery的調整大小圖像的SVG
- 30. 調整包含縮放圖像的父div的大小