• Stars
    star
    563
  • Rank 79,150 (Top 2 %)
  • Language
    C
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

cross platform screen/window capturing library

Above Logo created by https://github.com/mansya

Master is where development happens and should NOT be considered stable. Use tags for stable releases.

Window/Linux/Mac

Cross-platform screen and window capturing library

No External Dependencies except:

linux: sudo apt-get install libxtst-dev libxinerama-dev libx11-dev libxfixes-dev

Platforms supported:

  • Windows 7 and Up
  • MacOS
  • Linux

The image format is raw BGRA 32 bits per pixel. Alpha is unused for onNewFrame and onFrameChanged except for onMouseChanged where it IS USED!

The data exists like this if you were to march through with a for loop [A,R,G,B], [A,R,G,B], [A,R,G,B]. For a read on why this is check out the post here post here

Examples

c++

https://github.com/smasherprog/screen_capture_lite/blob/master/Example_CPP/Screen_Capture_Example.cpp

//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#

https://github.com/smasherprog/screen_capture_lite/blob/master/Example_CSharp/Program.cs

//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);

Library Usage

Only define what are are interested in. Do not define a callback for onMouseChanged if you dont want that information. If you do, the library will assume that you want mouse information and monitor that --so DONT!

Again, DONT DEFINE CALLBACKS FOR EVENTS YOU DONT CARE ABOUT. If you do, the library will do extra work assuming you want the information.

The library owns all image data so if you want to use it for your own purpose after the callback has completed you MUST copy the data out!

Each monitor or window will run in its own thread so there is no blocking or internal synchronization. If you are capturing three monitors, a thread is capturing each monitor.

ICaptureConfiguration

Calls to ICaptureConfiguration cannot be changed after start_capturing is called. You must destroy it and recreate it!

  • ICaptureConfiguration::onNewFrame: This will call back when a new frame is ready on the interval specified in SCL_SetFrameChangeInterval
  • ICaptureConfiguration::onFrameChanged: This will call back when differences are detected between the last frame and the current one. This is usefull when you want to stream data that you are only sending what has changed, not everything!
  • ICaptureConfiguration::onMouseChanged: This will call back when the mouse has changed location or the mouse image has changed up to a maximum rate specified in SCL_SetMouseChangeInterval

IScreenCaptureManager

Calls to IScreenCaptureManager can be changed at any time from any thread as all calls are thread safe!

  • IScreenCaptureManager::SCL_SetFrameChangeInterval: This will set the maximum rate that the library will attempt to capture frame events.
  • IScreenCaptureManager::SCL_SetMouseChangeInterval: This will set the maximum rate that the library will attempt to capture mouse events.
  • IScreenCaptureManager::pause: all threads will stop capturing.
  • IScreenCaptureManager::SCL_IsPaused: obvious!
  • IScreenCaptureManager::SCL_Resume: all threads will SCL_Resume capturing.

More Repositories

1

rat_lite

cross platform Remote Access Library
C++
238
star
2

RemoteDesktop

Remote Desktop Sharing V2
C++
59
star
3

input_lite

cross platform input library for simulating keyboard and mouse events
C++
32
star
4

CpuMem_Monitor

Cross platform cpu and memory monitor
C++
16
star
5

VNC_Proxy

VNC_Proxy / Repeater
C#
16
star
6

Destination_Toolkit

A tookit for video game development
C
13
star
7

Desktop_Sharing

Remote Desktop Sharing V1
C#
13
star
8

websocket_lite

cross platform web socket library
C++
10
star
9

EqTool

p99 everquest spell timer, dps and map
C#
10
star
10

Assimp_Animation_Helper

Assimp animation pre processor
C++
7
star
11

socket_lite

cross platform asynchronous networking library
C++
7
star
12

VM_Manager

A c# vm managing tool built on libvirt
C#
5
star
13

Wmi-Toolkit

Toolkit for WMI functions
C#
4
star
14

NWork

lightweight Reliable UDP Library
C++
4
star
15

android_background

Android Background service
C#
3
star
16

Libvirt_WebManager

C# Libvirt Web Manager
JavaScript
3
star
17

sl_engine

opengl 3d engine
C
2
star
18

Block_SizeReporter

Filesize block reporter utilitiy
C#
2
star
19

Backup

c# usn journal backup
C#
2
star
20

Openssl-VS

openssl builds for visual studio
C
2
star
21

Libvirt_Windows_CSharpDevelopment

Libvirt CSharp Nuget package
C#
2
star
22

fltk_nuget

fltk nuget package
C++
2
star
23

PythonNetInstaller

C#
1
star
24

Libjpeg-turbo-VS

libjpeg-turbo visual studio projects
C
1
star
25

EFTempTables

Entity Framework (ef) Temporary Tables for SQL
C#
1
star
26

Desktop_Checker

testing
C++
1
star
27

cryptopp-VS

visual studio projects for building cryptopp
1
star
28

SLGenerator

Sl Generator - A Visual studio plugin to dynamically run .net code inside visual studio
C#
1
star