Fit image from webcam in picturebox

Saga 426 Reputation points

Hi all,

I am using both Windows 7 and Windows 11. On Win 7 I have Visual Studio 2015 and on Win 11 I am using Visual Studio 2019. Using C#.

I am putting together an app that captures an image from a Webcam. Imagine creating a badge with a photo. The person steps in front of the Web cam, an image is transferred to a picture box and then saved. The photo is small, much like a driver license or passport photo.

I have the image capture working, but I can't tweak the picture box so that the photo looks right. I have used different SizeMode settings:

Normal and CenterImage: The image inside the picture box looks huge. If I place my face in front of the camera all I see in the picture bx are my nostrils.
AutoSize: Picture box changes to huge size.
Zoom: Webcam image displays as a tiny widescreen inside the picture box.
StretchImage: This is the closest, but the captured image is squished vertically and does not look right.

I am currently looking into options on how to tweak the StretchedImage so that it looks more realistic size-wise. Any advice or orientation is greatly appreciated. Thank you for your time and assistance. Saga

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,405 questions
{count} votes