public Task <IScreenshotResult> CaptureAsync() { var img = UIScreen.MainScreen.Capture(); var result = new ScreenshotResult(img); return(Task.FromResult(result)); }
public Task <IScreenshotResult> CaptureAsync(UIView view) { _ = view ?? throw new ArgumentNullException(nameof(view)); // NOTE: We rely on the view frame having been set to the correct size when this method is invoked. UIGraphics.BeginImageContextWithOptions(view.Bounds.Size, false, view.Window.Screen.Scale); var ctx = UIGraphics.GetCurrentContext(); // ctx will be null if the width/height of the view is zero if (ctx != null) { if (!TryRender(view, out var error)) { // FIXME: test/handle this case } } var image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); var result = new ScreenshotResult(image); return(Task.FromResult <IScreenshotResult>(result)); }
public Task <IScreenshotResult> CaptureAsync(UIWindow window) { _ = window ?? throw new ArgumentNullException(nameof(window)); // NOTE: We rely on the window frame having been set to the correct size when this method is invoked. UIGraphics.BeginImageContextWithOptions(window.Bounds.Size, false, window.Screen.Scale); var ctx = UIGraphics.GetCurrentContext(); if (!TryRender(window, out var error)) { // FIXME: test/handle this case } // Render the status bar with the correct frame size TryHideStatusClockView(UIApplication.SharedApplication); var statusbarWindow = GetStatusBarWindow(UIApplication.SharedApplication); if (statusbarWindow != null /* && metrics.StatusBar != null*/) { statusbarWindow.Frame = window.Frame; statusbarWindow.Layer.RenderInContext(ctx); } var image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); var result = new ScreenshotResult(image); return(Task.FromResult <IScreenshotResult>(result)); }
public Task <IScreenshotResult> CaptureAsync(CALayer layer, bool skipChildren) { _ = layer ?? throw new ArgumentNullException(nameof(layer)); // NOTE: We rely on the layer frame having been set to the correct size when this method is invoked. UIGraphics.BeginImageContextWithOptions(layer.Bounds.Size, false, layer.RasterizationScale); var ctx = UIGraphics.GetCurrentContext(); // ctx will be null if the width/height of the view is zero if (ctx != null) { if (!TryRender(layer, ctx, skipChildren, out var error)) { // FIXME: test/handle this case } } var image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); var result = new ScreenshotResult(image); return(Task.FromResult <IScreenshotResult>(result)); }
public Task <IScreenshotResult> CaptureAsync(View view) { _ = view ?? throw new ArgumentNullException(nameof(view)); var bitmap = Render(view); var result = new ScreenshotResult(bitmap); return(Task.FromResult <IScreenshotResult>(result)); }