0

I am trying to get normal video output from my camera inside of my windows forms application. Since it was cropping the video output otherwise I am resizing it. I made the picture box size 640 to 360 so it should be half of my 1280 to 720 built-in camera. However, the image output is stretched horizontally. the code that I am resizing is this one:

Bitmap unresized = (Bitmap)eventArgs.Frame.Clone();
Bitmap newFrame = new Bitmap(unresized, 640, 360);
pictureBox1.BeginInvoke(new Action(() =>
                {
                    pictureBox1.Image = newFrame;
                }));

How can I make it so that it does the conversion without distorting the image?

1 Answers1

1

You should likely just change the SizeMode of your picturebox:

pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;

This should fit the image to your picture box, while maintaining the aspect ratio. There should be no need to manually resize an image.

JonasH
  • 28,608
  • 2
  • 10
  • 23