screen_capture_lite

smasherprogMIT更新放缓

跨平台屏幕与窗口捕获 C 库,基于 Desktop Duplication API 等后端,为录屏、截图和屏幕共享工具提供底层采集能力。

cross platform screen/window capturing library

17.1.1368发布于 2023-08-14 13:42 UTC728star163fork同步于 2026-11-07 07:33 UTC

怎么上手

由 README 提炼,执行前请确认
sudo apt-get install libxtst-dev libxinerama-dev libx11-dev libxfixes-dev
硬件要求按 README 说明

README 未说明显存或 GPU 要求;支持 Windows 7 及以上、macOS、Linux。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

跨平台屏幕与窗口捕获 C++ 库,提供 C# 绑定,按需回调帧变化与鼠标事件

跨平台屏幕与窗口捕获 C 库,基于 Desktop Duplication API 等后端,为录屏、截图和屏幕共享工具提供底层采集能力。

核心能力

  • 按显示器或窗口标题过滤捕获目标
  • 提供 onNewFrame、onFrameChanged、onMouseChanged 三类回调
  • 每个显示器或窗口独立线程捕获,无内部阻塞
  • 可设置帧与鼠标事件的最大回调间隔
  • 输出原始 BGRA 32 位像素数据

容易踩的坑

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

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本17.1.1368
  1. 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

  2. 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

  3. 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

  4. 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

  5. 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

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译
    //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);