protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == TakeImageId && resultCode != 0 && _File != null) { Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile); Android.Net.Uri contentUri = Android.Net.Uri.FromFile(_File); mediaScanIntent.SetData(contentUri); Application.Context.SendBroadcast(mediaScanIntent); Bitmap bitmap = MediaStore.Images.Media.GetBitmap(ContentResolver, contentUri); Bitmap formattedBitmap = Bitmap.CreateScaledBitmap(bitmap, appPreferences.GetImageWidth(bitmap.Width), appPreferences.GetImageHeight(bitmap.Height), false); if (formattedBitmap != null) { if (IsFirstPhoto) { facilityPhoto.SetImageBitmap(formattedBitmap); FirstPhotoIsChanged = true; } else { secondFacilityPhoto.SetImageBitmap(formattedBitmap); SecondPhotoIsChanged = true; } } bitmap = null; GC.Collect(); } else { if (data != null) { Bitmap bitmap = MediaStore.Images.Media.GetBitmap(ContentResolver, data.Data); if (IsFirstPhoto) { facilityPhoto.SetImageBitmap(Bitmap.CreateScaledBitmap(bitmap, appPreferences.GetImageWidth(bitmap.Width), appPreferences.GetImageHeight(bitmap.Height), false)); FirstPhotoIsChanged = true; } else { secondFacilityPhoto.SetImageBitmap(Bitmap.CreateScaledBitmap(bitmap, appPreferences.GetImageWidth(bitmap.Width), appPreferences.GetImageHeight(bitmap.Height), false)); SecondPhotoIsChanged = true; } GC.Collect(); } } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); AppPreferences ap = new AppPreferences(Application.Context); if (requestCode == TakeImageId && resultCode != 0) { Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile); Android.Net.Uri contentUri = Android.Net.Uri.FromFile(_file); mediaScanIntent.SetData(contentUri); SendBroadcast(mediaScanIntent); Bitmap bitmap = MediaStore.Images.Media.GetBitmap(ContentResolver, contentUri); iImageViewer.SetImageBitmap(Bitmap.CreateScaledBitmap(bitmap, ap.GetImageWidth(bitmap.Width), ap.GetImageHeight(bitmap.Height), false)); } else { if (data != null) { Bitmap bitmap = MediaStore.Images.Media.GetBitmap(ContentResolver, data.Data); iImageViewer.SetImageBitmap(Bitmap.CreateScaledBitmap(bitmap, ap.GetImageWidth(bitmap.Width), ap.GetImageHeight(bitmap.Height), false)); } } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); AppPreferences ap = new AppPreferences(Application.Context); if (requestCode == TakeImageId && resultCode != 0 && _File != null) { Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile); Android.Net.Uri contentUri = Android.Net.Uri.FromFile(_File); mediaScanIntent.SetData(contentUri); Application.Context.SendBroadcast(mediaScanIntent); int height = Resources.DisplayMetrics.HeightPixels; int width = Resources.DisplayMetrics.WidthPixels; Android.Graphics.Bitmap bitmap = _File.Path.LoadAndResizeBitmap(ap.GetImageWidth(width), ap.GetImageHeight(height)); if (bitmap != null) { if (IsFirstPhoto) { facilityPhoto.SetImageBitmap(bitmap); FirstPhotoIsChanged = true; } else { secondFacilityPhoto.SetImageBitmap(bitmap); SecondPhotoIsChanged = true; } } bitmap = null; GC.Collect(); } else { if (data != null) { Android.Net.Uri uri = data.Data; if (IsFirstPhoto) { facilityPhoto.SetImageURI(uri); FirstPhotoIsChanged = true; } else { secondFacilityPhoto.SetImageURI(uri); SecondPhotoIsChanged = true; } GC.Collect(); } } }