Skip to content

Conversation

@DigitApps2
Copy link

No description provided.

@janusw
Copy link
Owner

janusw commented Jun 27, 2025

@DigitApps2 Thanks for the carry-over from hjam40#172 !

@janusw janusw mentioned this pull request Jun 28, 2025
Copy link
Owner

@janusw janusw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that this fixes the problem from #40, as seen on the FullScreenPage of the Camera.MAUI.Test app.

However, I do feel like the fix is a bit "hacky". There is already some dedicated logic for choosing a video size here:

private Size ChooseVideoSize(Size[] choices)
{
Size result = choices[0];
int diference = int.MaxValue;
bool swapped = IsDimensionSwapped();
foreach (Size size in choices)
{
int w = swapped ? size.Height : size.Width;
int h = swapped ? size.Width : size.Height;
if (size.Width == size.Height * 4 / 3 && w >= Width && h >= Height && size.Width * size.Height < diference)
{
result = size;
diference = size.Width * size.Height;
}
}
return result;
}

I guess it would be better to fix it there than to always enforce the maximum video size.

@janusw
Copy link
Owner

janusw commented Jun 28, 2025

However, I do feel like the fix is a bit "hacky". There is already some dedicated logic for choosing a video size here:

private Size ChooseVideoSize(Size[] choices)

What this method does is to choose the smallest possible video size that is bigger than the size of the CameraView.

The problem of bad resolution apparently occurs if the preview is started already before the view has obtained a proper size: Width and Height are both still zero, and consequently the smallest video size overall is chosen, leading to poor resolution.

IMHO a more appropriate fix would be to modfiy ChooseVideoSize such that it falls back to using ChooseMaxVideoSize if either Width or Height are zero. I'll prepare an alternative PR which does that ...

@DigitApps2 DigitApps2 closed this Jun 28, 2025
@janusw janusw mentioned this pull request Jun 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants