2

As title, I want to crop a image which size is 500*500, It works on most device(like htc,sonyerrison,motors..),but samsung(Sii/Ace...).

Actually, Samsung Device can work on 360*360,but when I resize to 500*500.

The Behavior is quite weird, when I put

 intent.putExtra("outputX", 500);
 intent.putExtra("outputY", 360);
 startActivityForResult(intent,PHOTORESOULT),

It nerver comes back to onActivityResult()

Here is the cropping code,and I am sure that there is a image in that uri

    public void startPhotoZoom(Uri uri) {

             Bitmap bitmap =null;
    try {
        bitmap = MediaStore.Images.Media.getBitmap(
                this.getContentResolver(), uri);
        Log.v("cropImage","Heigh="+bitmap.getHeight()+" Width="+bitmap.getWidth());
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    int width=bitmap.getWidth();
    int height=bitmap.getHeight();

    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(uri, IMAGE_UNSPECIFIED);
    intent.putExtra("crop", "true");
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    if(width < 500 || height < 500){
        if(width <= height){
            intent.putExtra("outputX", width); 
            intent.putExtra("outputY", width);
            Log.v("cropImage","outputX="+width+" outputY="+width);
        }else{
            intent.putExtra("outputX", height); 
            intent.putExtra("outputY", height);
            Log.v("cropImage","outputX="+height+" outputY="+height);
        }
    }else{
        intent.putExtra("outputX", 360);
        intent.putExtra("outputY", 360);
    }

    intent.putExtra("noFaceDetection", true);
    intent.putExtra("scale", true);
    intent.putExtra("return-data", true);
    startActivityForResult(intent, PHOTORESOULT);
}

I am struggling for a while~ Please Help~

Deepak Swami
  • 3,838
  • 1
  • 31
  • 46
hubert
  • 21
  • 1
  • 3
  • please mark the answer below since it's correct. Also check out: http://stackoverflow.com/questions/12758425/how-to-set-the-output-image-use-com-android-camera-action-crop/ for more details – hcpl Apr 17 '13 at 09:15

2 Answers2

6

I assume, the cropped image is simply too big. To be relly sure you should read logcat.

I had the same Problem, that too large Image wouldnt be passed to onActivityResult and had to let the cropped image be saved to disk an then load it seperately.

simply omit

 intent.putExtra("return-data", true);

and set

 Uri destination;
 // some code to retriev an valid Uri
 intent.putExtra(MediaStore.EXTRA_OUTPUT, destination);

instead. Be sure that the Uri destination points to a file.

user1576140
  • 61
  • 1
  • 2
-1

You can change like this,and you will get the exact cropped image from onActivityResult()

intent.putExtra("return-data", false);
Arun Kumar
  • 100
  • 1
  • 2
  • 12