When I am calling this function there is no image/string in _bitmap. In my application, I select image from the gallery and convert it to base64. I had debugged the app for the problem, so I found that the method BitmapFactory.decodeFile("image path")
is returning null
value even though the path which I am getting is totally fine.
private void _btnResimYolu_Click(object sender, System.EventArgs e)
{
var imageIntent = new Intent();
imageIntent.SetType("image/*");
imageIntent.SetAction(Intent.ActionGetContent);
StartActivityForResult(Intent.CreateChooser(imageIntent, "Select Image"), 0);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (resultCode == Result.Ok)
{
var imageView = FindViewById<ImageView>(Resource.Id.img1);
imageView.SetImageURI(data.Data);
_imageTest.Text = data.DataString;
}
}
private void _gonder_Click(object sender, System.EventArgs e)
{
string uriString = _imageTest.Text;
_bitmap = BitmapFactory.DecodeFile(uriString);
MemoryStream stream = new MemoryStream();
_bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
byte[] ba = stream.ToArray();
string bal = Base64.EncodeToString(ba, Base64.Default);
}