Current Behavior
When using CommunityToolkit.CameraView, the image captured is larger than the preview displayed on the camera page. This results in a mismatch between the visible area in the CameraView and the actual captured image.
CameraView:
Result:
Expected Behavior
The captured image should match the preview area displayed in the CameraView.
Reproduction Sample
https://github.com/MoienTajik/MauiCameraIssue
Steps To Reproduce
- Implement the
CameraView as shown below:
XAML:
<toolkit:CameraView x:Name="CameraView"
VerticalOptions="Fill"
HorizontalOptions="Fill"
CameraFlashMode="Off"
MediaCaptured="OnMediaCaptured" />
C# Code Behind:
protected override async void OnAppearing()
{
base.OnAppearing();
await _cameraProvider.RefreshAvailableCameras(CancellationToken.None);
CameraView.SelectedCamera = _cameraProvider.AvailableCameras
.FirstOrDefault(c => c.Position == CameraPosition.Rear);
}
private async void OnCaptureButtonClicked(object sender, EventArgs e)
{
if (!CameraView.IsAvailable)
{
await DisplayAlert("Camera Unavailable", "Camera is not available.", "OK");
return;
}
try
{
await CameraView.CaptureImage(CancellationToken.None);
}
catch
{
// Ignore exceptions
}
}
private async void OnMediaCaptured(object? sender, MediaCapturedEventArgs e)
{
try
{
using var stream = (MemoryStream)e.Media;
_stateService.CapturedPhotos.Add(stream.ToArray());
}
catch
{
// Ignore exceptions
}
}
- Capture an image using the
CameraView.
Environment
- .NET MAUI CommunityToolkit: 9.1.0
- .NET MAUI CommunityToolkit.Camera: 1.0.5
- OS: MacOS Sequoia 15
- .NET MAUI: 9.0.0-rc.2.24503.2
Anything else?
Same issue in another Camera related repo: hjam40/Camera.MAUI#98
Current Behavior
When using
CommunityToolkit.CameraView, the image captured is larger than the preview displayed on the camera page. This results in a mismatch between the visible area in theCameraViewand the actual captured image.CameraView:
Result:
Expected Behavior
The captured image should match the preview area displayed in the
CameraView.Reproduction Sample
https://github.com/MoienTajik/MauiCameraIssue
Steps To Reproduce
CameraViewas shown below:XAML:
C# Code Behind:
CameraView.
Environment
Anything else?
Same issue in another Camera related repo: hjam40/Camera.MAUI#98