Android camera.action.CROP未按预期工作

Android camera.action.CROP未按预期工作,android,Android,我已经为一个问题挣扎了几天,我想不出任何解决办法,我所有的研究都完成了 我有一个简单的相机/图库意图,然后是裁剪意图 到目前为止,我遇到了两个问题 在华为P9上,祝酒词上的“保存图片”似乎很成功,但似乎裁剪屏幕还没有完成,因为之后什么也没有发生 在三星Galaxy S8和S8上加上裁剪后的图像质量很差 我的裁剪方法如下: protected void performCrop(File file) { // take care of exceptions try

我已经为一个问题挣扎了几天,我想不出任何解决办法,我所有的研究都完成了

我有一个简单的相机/图库意图,然后是裁剪意图

到目前为止,我遇到了两个问题

  • 在华为P9上,祝酒词上的“保存图片”似乎很成功,但似乎裁剪屏幕还没有完成,因为之后什么也没有发生

  • 在三星Galaxy S8和S8上加上裁剪后的图像质量很差

  • 我的裁剪方法如下:

    protected void performCrop(File file) {
    
            // take care of exceptions
            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(Uri.fromFile(file), "image/*");
                // set crop properties
                cropIntent.putExtra("crop", "true");
                // indicate aspect of desired crop
                cropIntent.putExtra("aspectX", ASPECT_X);
                cropIntent.putExtra("aspectY", ASPECT_Y);
    //            // 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
                cropIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
                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();
            }
        }
    

    正如你所看到的,我尝试了不同的可能性和解决方案,但没有任何效果。如果有人知道我如何解决这个问题,请告诉我。

    我建议您不要使用内置的作物操作。我和很多人打过交道,我也和很多人打过交道。没有保证,因为有100种设备和1000种应用程序以自己的方式处理裁剪意图。即使你让它在一些地方起作用,你也会留下一些它不起作用的地方。您可以创建自己的裁剪器,也可以使用第三方库进行图像裁剪。有很多可用的开源库。这样,您就拥有了all控件,它也可以在所有设备上工作。这有意义吗?是的,已经开始查找一些库了。谢谢你的建议。