
https://github.com/mansya创建的上述徽标
主人是发生发展的地方,不应被视为稳定。使用标签进行稳定版本。
窗口/Linux/Mac
跨平台屏幕和窗口捕获库
Linux:sudo apt-get安装libxtst-dev libxinerama-dev libx11-dev libxfixes-dev
图像格式为RAW BGRA每个像素32位。 Alpha未使用newframe,除了使用该空格的地方,并且使用了framechang!
如果您要使用A for循环[A,R,G,B],[A,R,G,B],[A,R,G,B],则数据存在。有关为什么这是在此处查看帖子的原因
https://github.com/smasherprog/screen_capture_lite/blob/master/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 ) ;仅定义您感兴趣的内容。如果您不想要这些信息,请不要为OnMousechangs定义回调。如果您这样做,库将假设您需要鼠标信息并监视 - 所以不要!
同样,不要为您不在乎的事件定义回调。如果这样做,假设您需要信息,则图书馆将进行额外的工作。
库拥有所有图像数据,因此,如果您想在回调完成后出于自己的目的使用它,则必须将数据复制出来!
每个监视器或窗口将以自己的线程运行,因此没有阻塞或内部同步。如果您要捕获三个显示器,则一个线程正在捕获每个监视器。
调用start_capturing后,无法更改对ICAPTURECONFIGURATION的调用。您必须销毁它并重新创建它!
可以随时从任何线程更改isCreencaptureManager的呼叫,因为所有呼叫都是线程安全的!