master 分支为开发版不稳定,应使用 tag 发布版;Linux 需先安装 libxtst、libxinerama、libx11、libxfixes 开发包;回调结束后图像数据归库所有,需自行拷贝出再使用;不要为不关心的事件注册回调,否则库会做额外工作。

screen_capture_lite
smasherprogMIT更新放缓跨平台屏幕与窗口捕获 C 库,基于 Desktop Duplication API 等后端,为录屏、截图和屏幕共享工具提供底层采集能力。
cross platform screen/window capturing library
sudo apt-get install libxtst-dev libxinerama-dev libx11-dev libxfixes-devREADME 未说明显存或 GPU 要求;支持 Windows 7 及以上、macOS、Linux。
跨平台屏幕与窗口捕获 C++ 库,提供 C# 绑定,按需回调帧变化与鼠标事件
跨平台屏幕与窗口捕获 C 库,基于 Desktop Duplication API 等后端,为录屏、截图和屏幕共享工具提供底层采集能力。
核心能力
- 按显示器或窗口标题过滤捕获目标
- 提供 onNewFrame、onFrameChanged、onMouseChanged 三类回调
- 每个显示器或窗口独立线程捕获,无内部阻塞
- 可设置帧与鼠标事件的最大回调间隔
- 输出原始 BGRA 32 位像素数据
容易踩的坑
- 17.1.2745pre-release2026-05-04 · 2026-05-04 18:35 UTC
查看更新说明
Fixed Example Code Extract to RGB code Added functions to check if application has permission to capture the screen, Request permission, and can request permission
- 17.1.2539pre-release2025-03-27 · 2025-03-27 18:26 UTC
查看更新说明
Fixed Example Code Extract to RGB code Added functions to check if application has permission to capture the screen, Request permission, and can request permission
- 17.1.1369pre-release2023-08-14 · 2023-08-14 13:49 UTC
查看更新说明
Fixed Example Code Extract to RGB code Added functions to check if application has permission to capture the screen, Request permission, and can request permission
- 17.1.1368最新正式版2023-08-14 · 2023-08-14 13:42 UTC
Fixed Example Code Extract to RGB code Added functions to check if application has permission to capture the screen, Request permission, and can request permission
- 17.1.1327pre-release2023-07-12 · 2023-07-12 13:52 UTC
查看更新说明
Fixed Example Code Extract to RGB code Added functions to check if application has permission to capture the screen, Request permission, and can request permission
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
//Setup Screen Capture for all monitors
auto framgrabber = SL::Screen_Capture::CreateCaptureConfiguration([]() {
//add your own custom filtering here if you want to capture only some monitors
return SL::Screen_Capture::SCL_GetMonitors();
})->onFrameChanged([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {
})->onNewFrame([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {
})->onMouseChanged([&](const SL::Screen_Capture::Image* img, const SL::Screen_Capture::MousePoint &mousepoint) {
})->start_capturing();
framgrabber->SCL_SetFrameChangeInterval(std::chrono::milliseconds(100));//100 ms
framgrabber->SCL_SetMouseChangeInterval(std::chrono::milliseconds(100));//100 ms
//Setup Screen Capture for windows that have the title "cmake" in it
auto windowframgrabber = SL::Screen_Capture::CreateCaptureConfiguration([]() {
auto windows = SL::Screen_Capture::SCL_GetWindows();
std::string srchterm = "cmake";
// convert to lower case for easier comparisons
std::transform(srchterm.begin(), srchterm.end(), srchterm.begin(), [](char c) { return std::tolower(c, std::locale());});
decltype(windows) filtereditems;
for(auto& a : windows) {
std::string name = a.Name;
std::transform(name.begin(), name.end(), name.begin(), [](char c) {return std::tolower(c, std::locale()); });
if(name.find(srchterm) != std::string::npos) {
filtereditems.push_back(a);
}
}
return filtereditems;
})->onFrameChanged([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Window& window) {
})->onNewFrame([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Window& window) {
})->onMouseChanged([&](const SL::Screen_Capture::Image* img, const SL::Screen_Capture::MousePoint &mousepoint) {
})->start_capturing();
windowframgrabber->SCL_SetFrameChangeInterval(std::chrono::milliseconds(100));//100 ms
windowframgrabber->SCL_SetMouseChangeInterval(std::chrono::milliseconds(100));//100 ms
c#
//Setup Screen Capture for all monitors
var framgrabber = SL.Screen_Capture.CaptureConfiguration.CreateCaptureConfiguration(() =>
{
var mons = SL.Screen_Capture.SCL_GetMonitors();
Console.WriteLine("Library is requesting the list of monitors to capture!");
for (int i = 0; i < mons.Length; ++i)
{
WriteLine( mons[i]);
}
return mons;
}).onNewFrame(( SL.Screen_Capture.Image img, SL.Screen_Capture.Monitor monitor) =>
{
}).onFrameChanged(( SL.Screen_Capture.Image img, SL.Screen_Capture.Monitor monitor) =>
{
}).onMouseChanged((SL.Screen_Capture.Image img, SL.Screen_Capture.MousePoint mousePoint) =>
{
}).start_capturing();
framgrabber.SCL_SetFrameChangeInterval(100);
framgrabber.SCL_SetMouseChangeInterval(100);
//Setup Screen Capture for windows that have the title "google" in it
var framgrabber = SL.Screen_Capture.CaptureConfiguration.CreateCaptureConfiguration(() =>
{
var windows = SL.Screen_Capture.SCL_GetWindows();
Console.WriteLine("Library is requesting the list of windows to capture!");
for (int i = 0; i < windows.Length; ++i)
{
WriteLine(windows[i]);
}
return windows.Where(a => a.Name.ToLower().Contains("google")).ToArray();
}).onNewFrame(( SL.Screen_Capture.Image img, SL.Screen_Capture.Window monitor) =>
{
}).onFrameChanged(( SL.Screen_Capture.Image img, SL.Screen_Capture.Window monitor) =>
{
}).onMouseChanged(( SL.Screen_Capture.Image img, SL.Screen_Capture.MousePoint mousePoint) =>
{
}).start_capturing();
framgrabber.SCL_SetFrameChangeInterval(100);
framgrabber.SCL_SetMouseChangeInterval(100);