using System.Drawing;
namespace ScreenShotDll
{
public class ScreenShotClass
{
public static void TakeScreenShotRect(int srcX, int srcY, int dstX, int dstY) //both fullscreen screenshot and cropped rectangle screenshot
{
int width = Math.Abs(srcX - dstX);
int height = Math.Abs(srcY - dstY);
Bitmap memoryImage;
memoryImage = new Bitmap(width, height);
Size s = new Size(memoryImage.Width, memoryImage.Height);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(srcX, srcY, 0, 0, s);
string str = "";
try
{
str = string.Format(AppDomain.CurrentDomain.BaseDirectory + @"Screenshot.png");
}
catch (Exception er)
{
Console.WriteLine("Sorry, there was an error: " + er.Message);
Console.WriteLine();
}
memoryImage.Save(str);
}
Unity 使用操作系统截图
最新推荐文章于 2024-04-23 15:09:23 发布