사용자 셀의 라이브러리에서 사진을 가져 오는 코드를 구현했지만 사용자가 Android 기본 자르기 UI를 사용하여 이미지자를 수 있도록 코드 우물을 사용하고 있습니다.자른 이미지 가져 오기
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 280);
intent.putExtra("outputY", 280);
intent.putExtra("scale", true);
startActivityForResult(intent , RESULT_CODE_PICK_FROM_LIBRARY);
다시 나는하여 onActivityResult에 코드를 사용하고 이미지를 얻을 수 있습니다 :
Uri selectedImage = data.getData();
String tempPath = getPath(selectedImage);
Bitmap pickedImage = BitmapFactory.decodeFile(tempPath);
getPath() :
private String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA }; // MediaColumns.DATA // MediaStore.Images.Media.DATA
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(projection[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
return filePath;
} else {
return null;
}
}
하지만 줄에 널 포인터 예외가 나타납니다.
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
아무도 이것에 관해 어떤 clew도 가지고 있습니까? 코드가 사진을 촬영을 자른 후 간단한 이미지를 검색 할 수있는 옵션이 제시 될 것입니다 무슨 또한 는 .. .. 원본 파일에 대한 필요가 없습니다
감사합니다, 뉴턴
제안에 감사드립니다.하지만이 튜토리얼은 촬영 한 사진을 파일로 저장하기 때문에 필자는 작은 크기의 사진 만 필요합니다 ... 또한 문서화되지 않은/개인 코드 (com.android)를 사용합니다. camera.action.CROP) 이것은 곧 지원을 느슨하게 할 수 있으며 모든 장치/osVersions에서도 작동하지 않습니다! –