0

当我从图库中选择一张照片时,它的宽度和高度总是 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天我一直在为此尝试,但我没有做。预先感谢您的帮助。

4

0 回答 0