title: Pass Camera OnActivityResult to Webservice to be Saved on Server as Image
body: <p>So I've gotten as far as getting the camera to open, take the picture and then return the camera result as follows:</p>
  
  <pre><code>bt.Click += delegate
     {
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
        StartActivityForResult(intent, 0);
     };
  protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
      {
          base.OnActivityResult(requestCode, resultCode, data);
  
          if (resultCode == Result.Ok &amp;&amp; requestCode == 0)
          {
              string result = data.ToURI();            
          }
  </code></pre>
  
  <p>The value of result ends up as "#Intent;action=inline-data;B.bitmap-data=true;end".  I don't really know where to go from here as far as taking the picture result and being able to turn it over to my web-service that will then save it as an image file on the server.  </p>
  
  <p>Edit:  The final code for anyone with the same problem</p>
  
  <pre><code>bt.Click += delegate
     {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    StartActivityForResult(intent, 0);
    };
  protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
   {
      Bitmap bitmap = (Android.Graphics.Bitmap)data.Extras.Get("data");
  
      using (var stream = new System.IO.MemoryStream())
      {
        bitmap.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 0, stream);
        byte[] imageBytes = stream.ToArray();
        string base64String = Convert.ToBase64String(imageBytes);
  
        inst.saveImage(base64String);
      }
   }
      [WebMethod]
      public void saveImage(string stream)
      {
          byte[] imageBytes = Convert.FromBase64String(stream);
          MemoryStream ms = new MemoryStream(imageBytes, 0,
            imageBytes.Length);
          var filepath = "C:\\Temp\\Test.png";
  
          using (Stream file = File.OpenWrite(filepath))
          {
              ms.CopyTo(file, (int)stream.Length);
          }
  
      }
  </code></pre>