Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid crop image size
    primarykey
    data
    text
    <p>I have the following code for users to crop image. When I set the size beyond 256, it does not work. My gut feel is "cropIntent.putExtra("return-data", true);" causing the error. How do I pass in the uri to cropIIntent and retrieve out from onActivityResults? In another words, save the image after crop and retrieve.</p> <pre><code>private void performCrop() { try { //call the standard crop action intent (the user device may not support it) Intent cropIntent = new Intent("com.android.camera.action.CROP"); //indicate image type and Uri cropIntent.setDataAndType(mImageCaptureUri, "image/*"); //set crop properties cropIntent.putExtra("crop", "true"); //indicate aspect of desired crop cropIntent.putExtra("aspectX", 4); cropIntent.putExtra("aspectY", 3); //indicate output X and Y cropIntent.putExtra("outputX", 256); cropIntent.putExtra("outputY", 256); //retrieve data on return cropIntent.putExtra("return-data", true); startActivityForResult(cropIntent, PIC_CROP); } //respond to users whose devices do not support the crop action catch (ActivityNotFoundException anfe) { //display an error message String errorMessage = "Your device doesn't support the crop action!"; Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT); toast.show(); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PIC_CROP) { try { final TextView imgTv = (TextView) findViewById(R.id.imageInfo); Bundle extras = data.getExtras(); thumbnail = extras.getParcelable("data"); ImageView image = (ImageView) findViewById(R.id.pestImage); image.setImageBitmap(thumbnail); File f = new File(mImageCaptureUri.getPath()); if (f.exists()) { f.delete(); } } }//end onactivity results </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload