Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 1429

How to capture the screen and save it to the file.

$
0
0

Hello Everyone. I'm not a experienced developer and i have a problem.

I don't understand how to make screenshot and save it to the file.

[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);   
        }

Not sure it's working properly. Can anyone help?


Viewing all articles
Browse latest Browse all 1429

Trending Articles