Asked
— Edited
Resolved by DJ Sures!
Hi Dj,
If I wanted to change the capture method from the entire screen to only what was in a picturebox, it looks like I would only need to change bmpScreenShot to point to my pictureBox, but when I ran it only one create a blank video (no errors) and for testing in the form load I set the value of pictureBox1 like this:
pictureBox1.ImageLocation = @"C:\Users\weyou_000\Pictures\test.jpg";
This is the section of code I'm looking at.
try {
_frameCnt++;
//Bitmap bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Bitmap bmpScreenShot = new Bitmap(pictureBox1.Bounds.Width, pictureBox1.Bounds.Height);
using (Graphics gfxScreenShot = Graphics.FromImage(bmpScreenShot)) {
gfxScreenShot.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
gfxScreenShot.DrawImageUnscaled(Properties.Resources.Cursor, Cursor.Position);
}
_writer.WriteVideoFrame(bmpScreenShot);
bmpScreenShot.Dispose();
Invokers.SetText(lblTime, string.Format("{0} (frame: {1}, skipped: {2})", DateTime.Now.Subtract(_startTime), _frameCnt, _skipCnt));
} finally {
_frameSkip = false;
}
}
Bump
I'm still looking for some advice to this question.
You can do this...
I'll give that a try. Thank you DJ!
Just remember that loading the picture box with image data from a file is slow and not thread safe.