I am using the jengelsma code from this post Capture Image from Camera and Display in Activity to get an image from the camera.
When I get the returned image it is only small and when I try to expand it I instantly lose the image quality.
I assume that this is only the preview size however I have been unable to find out to return the large image as it is this I need in order to manipulate it.
For reference the code is:
package edu.gvsu.cis.masl.camerademo;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MyCameraActivity extends Activity {
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.imageView = (ImageView)this.findViewById(R.id.imageView1);
Button photoButton = (Button) this.findViewById(R.id.button1);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
}
}
Any help greatly appreciated.
You have to do a bit extra to get a fullsize picture, it doesn't pass it in the Intent, but stores it in a file.
To start the camera for this, add an extra to your Intent:
getOutputMediaFileUri looks like:
Naturally you can modify the method that creates the file however you like to modify the naming.
Then in your onActivityResult you can get the URI to the picture by simply calling
getData()
on the Intent.start intent for camera
capture result in onActivityResult
in manifest