我在我的应用程序中集成了裁剪图像库,其中包含通过相机拍摄并使用拍摄的图片的功能。我的开发人员已按预期完成了此操作,但现在当我通过相机拍摄照片并将其设置在裁剪页面上时,在设置之前会变得模糊。我的开发人员因某些任务而不在覆盖范围内。我已经问过库开发人员,他们给了我以下集成代码的解决方案。
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);Uri outputFileUri = Uri.fromFile(new File(context.getExternalCacheDir().getPath(), "pickImageResult.jpeg"));intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
我的开发人员已经在我的应用程序中集成了以下代码:
@Override
public void onClick(DialogInterface dialog, int which) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent,REQ_PHOTO_CAMERA);
}
}
as well method like below
public final int REQ_PHOTO_CAMERA=243;
public final int REQ_PHOTO_GALLERY=346;
public final int REQ_APP_GALLERY=427;
public final int ACTION_CHANGE_BACKGROUND=1;
public final int ACTION_CHANGE_AUTHOR=2;
private int mChangeAction;
public void onActivityResult(int req,int res,Intent data){
if(res==RESULT_OK){
if(req==REQ_PHOTO_CAMERA){
Bitmap cameraImg = (Bitmap) data.getExtras().get("data");
cropAndSaveImage(cameraImg);
//updateCustomImage(cameraImg);
}else if(req==REQ_PHOTO_GALLERY){
try {
Bitmap imgGallery = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), data.getData());
// updateCustomImage(imgGallery);
cropAndSaveImage(imgGallery);
} catch (IOException e) {
// e.printStackTrace();
}
}else if (req == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
Uri resultUri = result.getUri();
Log.e("ImageUrl",resultUri.getPath());
updateCustomImage(BitmapFactory.decodeFile(resultUri.getPath()));
}else if(req==REQ_APP_GALLERY){
String imgPath=data.getStringExtra("ImagePath");
try {
InputStream inputStream=getAssets().open(imgPath);
Bitmap image=BitmapFactory.decodeStream(inputStream);
cropAndSaveImage(image);
} catch (IOException e) {
}
}
}
}
public void cropAndSaveImage(Bitmap imgPicked){
ImageLoader.getInstance().saveTempImage(imgPicked);
CropImage.activity(ImageLoader.getInstance().getTempImageUri())
.setInitialCropWindowPaddingRatio(0)
.setFixAspectRatio(false)
.setAspectRatio(1,2)
.setGuidelines(CropImageView.Guidelines.ON)
.start(this);
}
请告诉我我错过了什么?
注意:我们使用了这个库:链接
谢谢
Bitmap cameraImg = (Bitmap) data.getExtras().get("data");
,因为它仅用于缩略图。 - Enzokie