How to take a screenshot with Mono C#?

Posted by vagabond on Stack Overflow See other posts from Stack Overflow or by vagabond
Published on 2010-04-27T08:18:55Z Indexed on 2010/04/28 7:33 UTC
Read the original article Hit count: 302

Filed under:
|

I'm trying to use use code get a screenshot in Mono C# but I'm getting a System.NotImplementedException when I call CopyFromScreen. My code works with .NET, so is there an alternate way of getting a screenshot using Mono?

Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
bitmap.Save(memoryStream, imageFormat);
bitmap.Save(@"\tmp\screenshot.png", ImageFormat.Png);

I am using Mono JIT compiler version 2.4.2.3 (Debian 2.4.2.3+dfsg-2)

© Stack Overflow or respective owner

Related posts about mono

Related posts about c#