Android Image Crop:输出x和输出y始终为160 px

时间:2018-11-08 22:59:50

标签: android image android-studio android-image android-crop

当我从图库中选择照片时,它的宽度和高度始终变为160像素。但是我想要的宽度和高度是640。

我使用的代码如下。

 private void photoChooser(){

    Intent photoPickerIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    photoPickerIntent.setType("image/*");
    photoPickerIntent.putExtra("crop", true );
    photoPickerIntent.putExtra("aspectX",4);
    photoPickerIntent.putExtra("aspectY",4);
    photoPickerIntent.putExtra("outputX",640);
    photoPickerIntent.putExtra("outputY",640);
    photoPickerIntent.putExtra("return-data", true);
    photoPickerIntent.putExtra("scale", true);
    photoPickerIntent.putExtra("outputFormat", 
    Bitmap.CompressFormat.JPEG.toString());
    startActivityForResult(photoPickerIntent, PICK_IMAGE);

}

我用来选择照片的代码;

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
     if(requestCode == PICK_IMAGE){
        try{
            final Bundle extras = data.getExtras();
            if(extras != null){
                Bitmap bitmap = extras.getParcelable("data");
                lastImage = bitmap;
                roundedBitmapDrawable2 = 
RoundedBitmapDrawableFactory.create(this.getResources(),bitmap);
                roundedBitmapDrawable2.setCircular(true);
                imgProfile.setImageDrawable(roundedBitmapDrawable2);

            }
        }catch (Throwable ex){
            ex.printStackTrace();
        }
    }
}

我已经尝试了3天,但是我没有做。预先感谢您的帮助。

0 个答案:

没有答案