Skip to content

Commit dc8c936

Browse files
committed
feat: add screenshot to readme
1 parent 8df10fc commit dc8c936

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ using var image = ImageSource.FromFile("logo.png");
124124
using var media = new MediaSource("Video", "video.mp4").SetLooping(true);
125125
```
126126

127+
## Screenshots
128+
129+
```csharp
130+
// Full source screenshot (returns BGRA pixels, width, height — or null)
131+
var screenshot = source.TakeScreenshot();
132+
if (screenshot != null)
133+
{
134+
using var bmp = new Bitmap((int)screenshot.Width, (int)screenshot.Height, (int)(screenshot.Width * 4),
135+
PixelFormat.Format32bppArgb, Marshal.UnsafeAddrOfPinnedArrayElement(screenshot.Pixels, 0));
136+
bmp.Save("screenshot.jpg", ImageFormat.Jpeg);
137+
}
138+
139+
// Cropped screenshot — only transfers the crop region from GPU
140+
var cropped = source.TakeScreenshot(cropX: 960, cropY: 200, cropWidth: 640, cropHeight: 160);
141+
```
142+
127143
## Encoders
128144

129145
```csharp

0 commit comments

Comments
 (0)