2

我有以下裁剪方法。当我打电话时,cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);我的屏幕挂在“保存图像”处。如果我不调用它,则裁剪后的图像不会写入文件。

private void crop() {
try {
    Intent cropIntent = new Intent("com.android.camera.action.CROP");

    cropIntent.setDataAndType(mImageCaptureUri, "image/*");

    cropIntent.putExtra("crop", "true");
     cropIntent.putExtra("aspectX", 4);
    cropIntent.putExtra("aspectY", 3);
     cropIntent.putExtra("outputX", 500);
    cropIntent.putExtra("outputY", 300);
    File f = new File(Environment.getExternalStorageDirectory(),
            "/temporary_holder.jpg");
    try {
        f.createNewFile();
    } catch (IOException ex) {
        Log.e("io", ex.getMessage());
    }
    uri = Uri.fromFile(f);
    cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);

    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();
}

}
4

1 回答 1

0

我有同样的问题,它坚持:cropIntent.putExtra("outputX", 500); ..太糟糕了,修复它的唯一方法就是取出电池..

但如果我采取cropIntent.putExtra("outputX", 200); 它工作正常..

(设备 HTC Sensation Z710e Android 4.0.3 (API 15))

于 2015-06-23T15:08:38.547 回答