0

Im trying to take an input from a webcam and only want the centre of the image (to passport size image).

I have a Picturebox with the webcam stream which I have set SizeMode to CentreImage. I then have a second picturebox which when I click the second picturebox i then need a cropped image i then save later (currently i get the whole original image when saving).

I have code to crop this image into the 2nd picturebox which works however it loses loads of quality. Is there a way to make this crop lossless?

        private void pictureBox1_Click(object sender, EventArgs e)
    {
        //picPhoto.Image = pic.Image;
        using (Bitmap bmp = new Bitmap(pic.Image))
            
        {
            var newImg = bmp.Clone(
                new Rectangle { X = ((pic.Image.Width/2)-(350/2)), Y = ((pic.Image.Height / 2) - (450 / 2)), Width = 350, Height = 450 },
                bmp.PixelFormat);
            picPhoto.Image = newImg;
        }
    }
Simon Wait
  • 65
  • 1
  • 4
  • Does this answer your question? [How resize image without losing quality](https://stackoverflow.com/questions/18084387/how-resize-image-without-losing-quality) – Heretic Monkey Jun 28 '22 at 14:07
  • 1
    Really, just search for ["resize image without losing quality \[c#\]"](https://stackoverflow.com/search?q=resize+image+without+losing+quality+%5Bc%23%5D) and you'll get plenty of hits... – Heretic Monkey Jun 28 '22 at 14:08
  • Can it be that the loss you see comes from viewing an 350x450 image zoomed (fullscreen)? – scaler Jun 28 '22 at 14:31

0 Answers0