CommunityToolkit / CommunityToolkit/Maui
[BUG] Captured image in CameraView is Larger than camera preview
- Dominant language
- C#
- Stars
- 2.7k
- Forks
- 500
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 7
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
1. Implement the `CameraView` as shown below:
**XAML:**
```xaml
```
**C# Code Behind:**
```csharp
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
}
}
```
2. 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: https://github.com/hjam40/Camera.MAUI/issues/98
Contributor guide
Research direction
Start with the linked MauiCameraIssue reproduction and the CameraView CaptureImage and MediaCaptured entry points shown in the report. Compare the displayed preview area with the captured output on the stated macOS/.NET MAUI environment; done means the captured image matches the visible CameraView area.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100