I'm currently attempting to take snapshot of a specified portion of my application's window from a specified starting coordinate (which is where my problem comes in).
Rectangle bounds = new Rectangle((this.Width/2)-400,(this.Height/2)-200, 800,400);
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb))
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
IntPtr hdc = graphics.GetHdc();
PrintWindow(this.axS.Handle, hdc, 0);
graphics.ReleaseHdc(hdc);
graphics.Flush();
string file = "example.png";
bitmap.Save(file, ImageFormat.Png);
}
}
I'm attempting to make a dynamic-adaptive method to take a screenshot of the center of the window, even after being resized. I'm not sure how to apply x
and y
to the screenshot as a starting point for the screenshot. Dimensions will always remain 800,400
and always taking a screenshot of the center of the application regardless of window size.
Every attempt I have pegged, the bitmap took a screenshot from 0 (+800), 0 (+400)
where 0, 0
I need to change.
Is Bitmap
capable of this? If not, what other method could I use?