I'm getting a bit confused from this description:
The caller may pass an extra EXTRA_OUTPUT to control where this image
will be written. If the EXTRA_OUTPUT is not present, then a small
sized image is returned as a Bitmap object in the extra field. This is
useful for applications that only need a small image. If the
EXTRA_OUTPUT is present, then the full-sized image will be written to
the Uri value of EXTRA_OUTPUT.
With NO EXTRA_OUTPUT
, it will return a "small sized image"?
With EXTRA_OUTPUT
, it will return a full sized image?
"Is returned as a Bitmap object in the extra field"...
On my onActivityResult
, I was just using Intent data
as the actual data. Am I supposed to be using data.getExtra
or something?
In the case you provide an Uri:
Intent action = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
action.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, myUri);
startActivityForResult(action, CAMERA_RESULT);
and then you retrieve it with (after the tests on requestCode and resultCode):
Bitmap bitmap = BitmapFactory.decodeFile(myUri, options);
In the other case:
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA_RESULT);
and your retrieve it with:
Bundle bundle = intent.getExtras();
Bitmap bitmap = (Bitmap) extras.get("data");
Here is an expansion of my comment. This snippet of code worked well for me in giving me the pixel data - getting grayscale data and imageview is in my post here
@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);
Hope this helps