这是我的评论的扩展。这段代码对我来说很有效,可以为我提供像素数据 - 获取灰度数据和图像视图在我的帖子中
@Override
public void onClick(View v) {
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//super.onActivityResult(requestCode, resultCode, data);
if(requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
final ContentResolver cr = getContentResolver();
final String[] p1 = new String[] {
MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATE_TAKEN
};
Cursor c1 = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, p1, null, null, p1[1] + " DESC");
if ( c1.moveToFirst() ) {
String uristringpic = "content://media/external/images/media/" +c1.getInt(0);
Uri uri = Uri.parse(uristringpic);
try {
Bitmap bm = android.provider.MediaStore.Images.Media.getBitmap(cr, uri);
希望这可以帮助