access to full resolution pictures from camera with MonoDroid

后端 未结 1 1189
北海茫月
北海茫月 2020-12-18 08:34

I\'m trying to find a way to access full resolution pictures from MonoDroid, after a long time of attempting to port the Java examples to MonoDroid and looking at how for ot

相关标签:
1条回答
  • 2020-12-18 09:17

    I'll simply posted the code that i have used in my project. Hope it will help you. I have also tried to set file name and path through ContentValues class, like it is described in Android wiki, but all was ineffectively, I think that it's some MonoDroid bug.

    private string _imageUri;
    
    private Boolean isMounted
    {
        get
        {
            return Android.OS.Environment.ExternalStorageState.Equals(Android.OS.Environment.MediaMounted);
        }
    }
    
    public void BtnCameraClick(object sender, EventArgs eventArgs)
    {
          var uri = ContentResolver.Insert(isMounted ? MediaStore.Images.Media.ExternalContentUri
                                  : MediaStore.Images.Media.InternalContentUri, new ContentValues());
         _imageUri = uri.ToString();
          var i = new Intent(MediaStore.ActionImageCapture);
          i.PutExtra(MediaStore.ExtraOutput, uri);
          StartActivityForResult(i, CAPTURE_PHOTO);
    }
    
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (resultCode == Result.Ok && requestCode == CAPTURE_PHOTO)
            {
              Toast.MakeText(this, string.Format("Image URI is {0}",_imageUri), ToastLength.Short).Show();    
            }
        }
    
    0 讨论(0)
提交回复
热议问题