Posted on 2006-11-05
Ok. Using a webcam to capture a pic of a client.
The web cam's orientation is landscape, I need to capture a portrait. So I make the picturebox the right size. I then want to capture what I see in the picture box. (top left of the webcam feed). The picbox however saves the whole feed, not just the part that is visible to me.
I have tried to use this, but cannot get it to work effectively.
bmpImage = New Bitmap(picCapture.Image)
recCrop = New Rectangle(0, 0, 96, 120)
bmpCrop = New Bitmap(recCrop.Width, recCrop.Height, bmpImage.PixelFormat)
gphCrop = Graphics.FromImage(bmpCrop)
recDest = New Rectangle(0, 0, 96, 120)
gphCrop.DrawImage(bmpImage, recDest, recCrop.X, recCrop.Y, recCrop.Width, recCrop.Height, GraphicsUnit.Pixel)
bmpCrop.Save(Application.StartupPath & "\tmp.jpg", Imaging.ImageFormat.Jpeg)
Depending on the size of recCrop, I either get a very small top left part of the pic, (pic dimensions of 96x120), but really its a VERY small part of the top left corner. If I make recCrop 640x480, I get a 640x480 pic with the top left the piece that I want.???