0
裁剪图像像什么应用配置文件PIC如何从画廊或相机像whatapp裁剪图像中的Android
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
select = "image";
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", width+20);
intent.putExtra("aspectY", 170);
intent.putExtra("outputX", width+20);
intent.putExtra("outputY", 150);
intent.putExtra("return-data", true);
startActivityForResult(Intent.createChooser(intent,"Complete action using"), 111);
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
if(requestCode ==111)
{
Bitmap photo2 = null;
Bundle extras2 = data.getExtras();
if (extras2 != null) {
photo2 = extras2.getParcelable("data");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
photo2.compress(Bitmap.CompressFormat.PNG, 100,byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
encoded = Base64.encodeToString(byteArray,Base64.DEFAULT);
Log.e("", "bitmap"+encoded);
Drawable d = new BitmapDrawable(getResources(),photo2);
imgprofile.setBackgroundDrawable(d);
}
}