Taking An Image And Cropping It
I'm following this tutorial: http://mobile.tutsplus.com/tutorials/android/capture-and-crop-an-image-with-the-device-camera/ I am trying to create a simple activity that has a 'take
Solution 1:
I have used this type of action.Here is my code with the following link:-Detail Description
I hope this will help you.I suggest you the following Lines where you should have your focus:-
Intent camera=newIntent();
camera.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
camera.putExtra("crop", "true");
Solution 2:
The cropping activity is part of the stock Android camera app. It may or may not be available on your device, especially if you are using a custom/vendor camera app. If you want this to work reliably, you have to take the code for the cropper and incorporate it into your own app.
Solution 3:
privatevoidperformCrop(){
}
Inside this method we are going to call an Intent to perform the crop, so let’s add “try” and “catch” blocks in case the user device does not support the crop operation:
try {
}
catch(ActivityNotFoundException anfe){
//display an error messageStringerrorMessage="Whoops - your device doesn't support the crop action!";
Toasttoast= Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
//call the standard crop action intent (the user device may not support it)IntentcropIntent=newIntent("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", 256);
cropIntent.putExtra("outputY", 256);
//retrieve data on return
cropIntent.putExtra("return-data", true);
//start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, PIC_CROP);
//keep track of cropping intentfinalintPIC_CROP=2;
Post a Comment for "Taking An Image And Cropping It"