public static void TestCapture() { Foundation.NSNumber mainScreen = (Foundation.NSNumber)AppKit.NSScreen.MainScreen.DeviceDescription["NSScreenNumber"]; using (CoreGraphics.CGImage cgImage = CreateImage(mainScreen.UInt32Value)) { // https://stackoverflow.com/questions/17334786/get-pixel-from-the-screen-screenshot-in-max-osx/17343305#17343305 // Get byte-array from CGImage // https://gist.github.com/zhangao0086/5fafb1e1c0b5d629eb76 AppKit.NSBitmapImageRep bitmapRep = new AppKit.NSBitmapImageRep(cgImage); // var imageData = bitmapRep.representationUsingType(NSBitmapImageFileType.NSPNGFileType, properties: [:]) Foundation.NSData imageData = bitmapRep.RepresentationUsingTypeProperties(AppKit.NSBitmapImageFileType.Png); long len = imageData.Length; byte[] bytes = new byte[len]; System.Runtime.InteropServices.GCHandle pinnedArray = System.Runtime.InteropServices.GCHandle.Alloc(bytes, System.Runtime.InteropServices.GCHandleType.Pinned); System.IntPtr pointer = pinnedArray.AddrOfPinnedObject(); // Do your stuff... imageData.GetBytes(pointer, new System.IntPtr(len)); pinnedArray.Free(); using (AppKit.NSImage nsImage = new AppKit.NSImage(cgImage, new System.Drawing.SizeF(cgImage.Width, cgImage.Height))) { // ImageView.Image = nsImage; // And now ? How to get the image bytes ? // https://theconfuzedsourcecode.wordpress.com/2016/02/24/convert-android-bitmap-image-and-ios-uiimage-to-byte-array-in-xamarin/ // https://stackoverflow.com/questions/5645157/nsimage-from-byte-array // https://stackoverflow.com/questions/53060723/nsimage-source-from-byte-array-cocoa-app-xamarin-c-sharp // https://gist.github.com/zhangao0086/5fafb1e1c0b5d629eb76 // https://www.quora.com/What-is-a-way-to-convert-UIImage-to-a-byte-array-in-Swift?share=1 // https://stackoverflow.com/questions/17112314/converting-uiimage-to-byte-array } // End Using nsImage } // End Using cgImage } // End Sub TestCapture
public override void LocalyticsDidTagEvent(string eventName, Foundation.NSDictionary attributes, Foundation.NSNumber customerValueIncrease) { Console.WriteLine("LocalyticsDidTagEvent: " + eventName); }