コード例 #1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            // Make it available in the gallery

            Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
            Uri    contentUri      = Uri.FromFile(App._file);

            mediaScanIntent.SetData(contentUri);
            SendBroadcast(mediaScanIntent);

            // Display in ImageView. We will resize the bitmap to fit the display
            // Loading the full sized image will consume to much memory
            // and cause the application to crash.

            int height = Resources.DisplayMetrics.HeightPixels;
            int width  = imgPhoto.Width;

            App.bitmap = App._file.Path.LoadAndResizeBitmap(width, height);
            if (App.bitmap != null)
            {
                var rotatedImage = RotateImage(App.bitmap, -90);
                imgPhoto.SetImageBitmap(rotatedImage);
                var base64 = BitmapHelpers.ConvertBitMapToBase64String(rotatedImage);
                commons.Instance.image = base64;
                App.bitmap             = null;
            }

            // Dispose of the Java side bitmap.
            GC.Collect();
        }