Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, May 30, 2018 7:47 PM
I am not able to find out dlls to be used in .Net Core for capturing a screen.
All replies (3)
Wednesday, November 13, 2019 11:24 AM âś…Answered | 2 votes
This is now possible using **System.Drawing.Common
**
var captureBmp = new Bitmap(1920, 1024, PixelFormat.Format32bppArgb);
using (var captureGraphic = Graphics.FromImage(captureBmp))
{
captureGraphic.CopyFromScreen(0, 0, 0, 0, captureBmp.Size);
captureBmp.Save("capture.jpg", ImageFormat.Jpeg);
}
It does require you to know the size of the screen as there no support for Screen.
I've only tested this on Windows, but it should work on Linux too.
He's a link to Scott Hanselman's blog using the library for image resizing. https://www.hanselman.com/blog/HowDoYouUseSystemDrawingInNETCore.aspx
Thursday, May 31, 2018 6:45 AM
Nope. .NET Core cannot assume that there is such a thing as a "screen".
You may be able to find third-party libraries for this, if you are running on a desktop.
Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.
Monday, June 4, 2018 2:21 AM
Hi Akshay S. Deshmukh,
Based on my test, the way I found which used to capture screen always use Bitmap. BitMap could not use in .Net Core. If it is possible, please use .Net.
Here are two examples in .Net.
https://code.msdn.microsoft.com/windowsdesktop/Saving-a-screenshot-using-C-6883abb3
https://www.developerfusion.com/code/4630/capture-a-screen-shot/
Best Regards,
Wendy
Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you.
Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].