1

我现在面临一个问题,当进入裁剪功能时,我的 Galaxy nexus 不断循环“加载图像”。下面是我的编码:

Intent openCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
startActivityForResult(openCamera, click_camera);

protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent){
            if (imageReturnedIntent != null)
                {if(requestCode == click_camera && resultCode == RESULT_OK) { 
                    picUri = imageReturnedIntent.getData();
                    Crop();             
                }

            else {
                **my coding part**
}

/* crop method */
private void Crop(){    
    try {

        //call the crop action from intent (default from device)
        Intent cropIntent = new Intent("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", 300);
        cropIntent.putExtra("outputY", 300);
        cropIntent.putExtra("scale", true);
        cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
        cropIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
        //retrieve data on return
        cropIntent.putExtra("return-data", true);
        //start the activity - we handle returning in onActivityResult
        startActivityForResult(cropIntent, PIC_CROP);  
    }
    //respond to users whose devices do not support the crop action
    catch(ActivityNotFoundException anfe){
        //display an error message
        String errorMessage = "Whoops - your device doesn't support the crop action!";
        Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
        toast.show();
    }
}

是我的裁剪功能错误吗?任何人都可以帮助解决问题吗?

4

1 回答 1

2

这就是我为自己的情况解决问题的方法。

拿着这个:

cropIntent.putExtra("outputX", 300);
cropIntent.putExtra("outputY", 300);

并更改:

cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);

原因:点这里

编辑

我找到了解决方案

cropIntent.putExtra("outputX", ANY VALUE);
cropIntent.putExtra("outputY", ANY VALUE);
cropIntent.putExtra("return-data", false);
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri);

查看裁剪后的图像

BitmapFactory.decodeFile(mImageCaptureUri.getPath());

享受 :)

于 2013-02-05T15:30:38.343 回答