How to take the picture taken from the camera, not the camera preview

2

Good afternoon guys, I'm using this multiplatform camera project of the xamarin.

In the Android part, I'm not getting maximum in the photo, I'm using this function:

System.Collections.Generic.IList<Android.Hardware.Camera.Size> sizes = parameters.SupportedPictureSizes;

    // Iterate through all available resolutions and choose one.
    // The chosen resolution will be stored in mSize.

    foreach (var size in sizes)
    {
        Console.WriteLine("Available resolution: " + size.Width + " " + size.Height);
        mSize = size;
        if (1920 <= size.Width & size.Height <= 1944)
        {
            Console.WriteLine("Chosen resolution: " + mSize.Width + " " + mSize.Height);

            parameters.SetPictureSize(mSize.Width, mSize.Height);
            orgPreviewWidth = mSize.Width;
            orgPreviewHeight = mSize.Height;

        }

It is taking the resolution I want, but I noticed that when saving the photo, saves with the size of the preview of the macera, which varies from mobile to mobile, as it generates a Bitmap of Preview(TextureView)

Here, I'll move the size of the preview, if I by the resolution of the photo I want, the screen is stretched all the way

textureView.LayoutParameters = new FrameLayout.LayoutParams(widht, height);

To save the photo:

var image = textureView.Bitmap;
var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath;
var folderPath = absolutePath + "/" + "Album";
var filePath = System.IO.Path.Combine(folderPath, string.Format(MainPage.data + contador + "_frente.jpg", Guid.NewGuid()));

var fileStream = new FileStream(filePath, FileMode.Create);
                        await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 100, fileStream);


fileStream.Close();
image.Recycle();

var intent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile);
                        var file = new Java.IO.File(filePath);
                        var uri = Android.Net.Uri.FromFile(file);
                        intent.SetData(uri);
                        Forms.Context.SendBroadcast(intent);

Does anyone know if there is a solution for this?

    
asked by anonymous 19.08.2016 / 21:58

0 answers