你好,请帮助我这方面我想从画廊中选择图片并裁剪图片并将图片保存在某个文件夹中
请在这方面帮助我
enter code here
private void ProfilePic_Click(object sender,EventArgs e) { Intent = new Intent();
Intent.SetType("image/*");
Intent.SetAction(Intent.ActionGetContent);
StartActivityForResult(Intent.CreateChooser(Intent, "EZ-Gift Profile Pic"), PickImageId);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if ((requestCode == PickImageId) && (resultCode == Result.Ok) && (data != null))
{
Android.Net.Uri uri = data.Data;
//Toast.MakeText(this, path, ToastLength.Long).Show();
Toast.MakeText(this, uri.ToString(), ToastLength.Long).Show();
ProfilePic.SetImageURI(uri);
string path = GetPathToImage(data.Data);
edit = prefs.Edit();
edit.PutString("ProfilePicUri", uri.ToString());
Toast.MakeText(this, uri.ToString(), ToastLength.Long).Show();
Toast.MakeText(this, path, ToastLength.Long).Show();
}
}
private string GetPathToImage(Android.Net.Uri contentURI)
{
ICursor cursor = ContentResolver.Query(contentURI, null, null, null, null);
cursor.MoveToFirst();
string documentId = cursor.GetString(0);
documentId = documentId.Split(':')[1];
cursor.Close();
cursor = ContentResolver.Query(
Android.Provider.MediaStore.Images.Media.ExternalContentUri,
null, MediaStore.Images.Media.InterfaceConsts.Id + " = ? ", new[] { documentId }, null);
cursor.MoveToFirst();
string path = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data));
cursor.Close();
return path;
}