gpt4 book ai didi

java - 我怎样才能从用户那里得到图像? api 使用 : image cropper, circleimageview

转载 作者:行者123 更新时间:2023-11-30 05:04:17 24 4
gpt4 key购买 nike

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(resultCode,requestCode,data);

if (requestCode == 12 && resultCode == RESULT_OK && data!= null) ;
{
CropImage.activity()
.setCropShape(CropImageView.CropShape.OVAL)

.start(this);

}
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
resultUri=result.getUri();
circleImageView.setImageURI(resultUri);


}
else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE)
{
Exception error = result.getError();


}
}


}

}

最佳答案

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

Log.d("APP_DEBUG", String.valueOf(requestCode));

try {
// When an Image is picked
if (requestCode == RESULT_SELECT_IMG && resultCode == Activity.RESULT_OK
&& null != data) {
Uri selectedImage = data.getData();

CropImage.activity(selectedImage)
.setGuidelines(CropImageView.Guidelines.ON)
.setMinCropResultSize(800, 800)
.setMaxCropResultSize(1000, 1000)
.start(this);
}
// when image is cropped
else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
Log.d("APP_DEBUG",result.toString());
if (resultCode == Activity.RESULT_OK) {
resultUri = result.getUri();
Log.d("APP_DEBUG",resultUri.toString());
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), resultUri);
circleImageView.setImageBitmap(bitmap);

} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
}
}
else {
Toast.makeText(this, "You haven't picked Image",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(this, "Something went wrong"+e.getMessage(), Toast.LENGTH_LONG)
.show();
}

关于java - 我怎样才能从用户那里得到图像? api 使用 : image cropper, circleimageview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54850024/

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