0
中的文件我不是一个有经验的开发人员,我遇到了问题。如何捕获屏幕并将其保存到Xamarin.Mac
我不明白如何制作截图并将其保存到文件中。
[DllImport("/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/CoreGraphics")]
private static extern IntPtr CGWindowListCreateImage(RectangleF screenBounds, CGWindowListOption windowOption, uint windowID, GWindowImageOption imageOption);
partial void ButtonClicked (Foundation.NSObject sender) {
IntPtr screenShot = CGWindowListCreateImage ((RectangleF)NSScreen.MainScreen.Frame, CGWindowListOption.IncludingWindow,
0, CGWindowImageOption.Default);
CGImage img = new CGImage(screenShot);
NSBitmapImageRep imgRep = new NSBitmapImageRep(img);
NSImage imgf = new NSImage(img, NSScreen.MainScreen.Frame.Size);
}
不确定它是否正常工作。谁能帮忙?