-
Notifications
You must be signed in to change notification settings - Fork 468
Open
Labels
Camera 📸Issue/PR associated with the Camera packageIssue/PR associated with the Camera packagebugSomething isn't workingSomething isn't workingunverified
Description
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
CameraViewas 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
sbricchi and NiSHoWNiSHoW and pmahend1
Metadata
Metadata
Assignees
Labels
Camera 📸Issue/PR associated with the Camera packageIssue/PR associated with the Camera packagebugSomething isn't workingSomething isn't workingunverified