c# windows grab screenshot
using System.Windows.Forms;
using Point = System.Drawing.Point;
using Rectangle = System.Drawing.Rectangle;
Rectangle bounds = Screen.GetBounds(Point.Empty);
using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using(Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
// will save to working directory ( for C# WPF in VS 2019: C:\Users\{user}\source\repos\{project}\{project}\bin\Debug )
bitmap.Save("test.jpg", ImageFormat.Jpeg);
}private Bitmap GetSreenshot()
{
Bitmap bm = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bm);
g.CopyFromScreen(0, 0, 0, 0, bm.Size);
return bm;
}
Also in C#:
- asp.net model display name
- c# razor add disabled to button if
- null coalesce ternary c#
- c# string replace comma with newline
- c# arraylist to listview
- unity if gameobject exists
- c# instantiate
- how to get component in unity c#
- c# Sleep
- Microsoft.AspNetCore.Components.Forms.InputSelect`1.TryParseValueFromString(String value, TValue& result, String& validationErrorMessage)
- get absolute url c#
- c# param exception
- open link c#
- multidimensional meaning
- Assets\playermove.cs(30,37): error CS1003: Syntax error, ',' expected
- unity movement on forward
- isdaylightsavingtime in c#
- c# shorten an method
- c# keyvaluepair
- unity array of child objects
- uinput dialog uwp c#
- asp.net core mvc not triggering client side validation
- mongodb custom IIdGenerator
- asp.net core allow all origins