gpt4 book ai didi

android - Galaxy Nexus 在使用 crop Intent 时出现循环

转载 作者:行者123 更新时间:2023-11-29 21:54:32 24 4
gpt4 key购买 nike

我现在面临一个问题,我的 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();
}
}

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

最佳答案

我是这样解决问题的。

拿这个:

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

并改变:

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

原因:click here

编辑

我找到了解决方案

设置

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

享受 :)

关于android - Galaxy Nexus 在使用 crop Intent 时出现循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13569697/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com