裁剪意图不适用于从相机拍摄的图像

时间:2016-04-26 12:56:56

标签: android image

我面临的问题是我有两个选项从相机或画廊拍照.....如果用户选择相机然后图像存储在SD卡上,然后显示给用户进行裁剪....但问题是当我尝试裁剪它显示的图像无法加载图像..... P.S如果从图库选项中选择相同的图像,那么没有问题,我能够顺利裁剪图像...任何帮助将不胜感激

仅供参考....我正在获取图像的路径

private void performCrop(Uri path) {
    // take care of exceptions
    try {
        Log.d(TAG,"path is in perform crop"+path);
        // 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(path,"image/*");
        // set crop properties
        cropIntent.putExtra("crop", "true");
        // indicate aspect of desired crop
        cropIntent.putExtra("aspectX", 0);
        cropIntent.putExtra("aspectY", 0);
        // 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, CROP_PIC);
    }
    // respond to users whose devices do not support the crop action
    catch (ActivityNotFoundException anfe) {
        Toast toast = Toast
                .makeText(this, "This device doesn't support the crop action!", Toast.LENGTH_SHORT);
        toast.show();
    }catch (Exception e){
        e.printStackTrace();
    }
}

0 个答案:

没有答案