我的应用程序有一个ImageView活动,我从手机图库中挑选一张图片,并将其设置在此ImageView中作为用户的个人资料图片。将从图库中选取的图像调整为图像视图
我的问题是,一些图片时,选择使应用程序停止原因是太大,我想知道如果有人可以看我的代码,并帮助我如何调整这张选择的图片,所以设置后,用户可以在设置之前剪下这张图片,下面是我的代码,我在这张图片上拍照。如果有人做了必要的改变,并且给我代码,我会非常感激,因为我对开发不了解太多。谢谢。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
PreferenceManager.getDefaultSharedPreferences(this).edit().putString("picturePath", picturePath).commit();
cursor.close();
ImageView imageView = (ImageView) findViewById(R.id.User);
imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
}
}
尝试,这是图像压缩像whtsapp我已经使用在我的应用程序中https://www.built.io/blog/2013/03/improving-image-compression-what-weve-learned-from-whatsapp/ –