2
Good afternoon guys, I’m using this Xamarin cross-platform camera design.
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;
}
he is taking the resolution I want, but I noticed that at the time of saving the photo, saved with the size of the preview of macera, which varies from mobile to mobile, because it generates a Bitmap of Preview(TextureView)
Here I pass the preview size, if I put the resolution of the photo I want, the screen is all stretched
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’s a solution to this?