Horje
c# windows grab screenshot Code Example
c# windows grab screenshot
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;
}
take screenshot in c#
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);
}




Csharp

Related
unity create random string Code Example unity create random string Code Example
how to find the mouse position unity Code Example how to find the mouse position unity Code Example
how to set a custom size for window in monogame Code Example how to set a custom size for window in monogame Code Example
how to detect collision in unity Code Example how to detect collision in unity Code Example
fade text unity Code Example fade text unity Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9