A cross-platform screenshot library for .NET that supports Windows, macOS, and Linux (X11/Wayland).
- Cross-platform support with native API calls
- Multiple capture targets: full screen, window, display, or region
- PNG and JPEG output formats
- No external dependencies beyond ImageSharp for image encoding
- Dependency injection friendly
- Configurable fallback behavior for unsupported features
dotnet add package Shutterusing Shutter;
// Capture entire screen
ScreenshotService screenshot = new();
byte[] imageData = screenshot.TakeScreenshot();
File.WriteAllBytes("screenshot.png", imageData);using Shutter;
using Shutter.Models;
using Shutter.Enums;
ScreenshotService screenshot = new();
// Capture a specific window
ScreenshotOptions options = new()
{
Target = CaptureTarget.Window,
WindowHandle = process.MainWindowHandle,
IncludeBorder = true,
IncludeShadow = false,
Format = ImageFormat.Jpeg,
JpegQuality = 85
};
byte[] imageData = screenshot.TakeScreenshot(options);| Feature | Windows | macOS | Linux/X11 | Linux/Wayland |
|---|---|---|---|---|
| Full Screen | ✅ | ✅ | ✅ | ✅ |
| Window Capture | ✅ | ❌ | ✅ | ❌ |
| Display Selection | ✅ | ✅ | ✅ | ❌ |
| Region Capture | ✅ | ✅ | ✅ | ❌ |
| Interactive Mode | ❌ | ❌ | ❌ | ✅ |
| Border Control | ✅ | ❌ | ❌ | ❌ |
| Shadow Control | ✅ | ❌ | ❌ | ❌ |
ScreenshotOptions options = new()
{
Target = CaptureTarget.Display,
DisplayIndex = 1 // Zero-based index
};
byte[] imageData = screenshot.TakeScreenshot(options);ScreenshotOptions options = new()
{
Target = CaptureTarget.Region,
Region = new Rectangle { X = 100, Y = 100, Width = 800, Height = 600 }
};
byte[] imageData = screenshot.TakeScreenshot(options);ScreenshotOptions options = new()
{
Interactive = true,
Timeout = TimeSpan.FromSeconds(30)
};
byte[] imageData = screenshot.TakeScreenshot(options);Configure how the library handles unsupported features:
ScreenshotOptions options = new()
{
Target = CaptureTarget.Window,
WindowHandle = handle,
Fallback = FallbackBehavior.ThrowException // Throws if feature unsupported
};Available fallback behaviors:
ThrowException- ThrowsPlatformNotSupportedExceptionfor unsupported featuresDefault- Falls back to full screen captureBestEffort- Attempts the closest available alternative
services.AddSingleton<IScreenshotService, ScreenshotService>();- .NET 8.0 or higher
- Windows: Windows 7 or higher
- macOS: macOS 10.12 or higher (uses CoreGraphics framework)
- Linux: X11 or Wayland session with appropriate libraries
- X11:
libX11installed - Wayland: DBus and XDG Desktop Portal support
- X11:
Shutter uses platform-specific native APIs:
- Windows: Win32 GDI and User32 APIs
- macOS: CoreGraphics framework (
CGDisplayCreateImage) - Linux/X11: libX11 (
XGetImage) - Linux/Wayland: DBus communication with XDG Desktop Portal
- Window capture is not supported on macOS (cannot obtain window IDs from .NET Process)
- Wayland only supports full screen capture or interactive selection due to security model
- Interactive mode is only available on Wayland
- Border and shadow control only available on Windows