
Logo di atas dibuat oleh https://github.com/mansya
Master adalah tempat pengembangan terjadi dan tidak boleh dianggap stabil. Gunakan tag untuk rilis yang stabil.
Window/Linux/Mac
Layar Cross-Platform dan Window Capturing Library
Linux: sudo apt-get install libxtst-dev libxinerama-dev libx11-dev libxfixes-dev
Format gambar adalah BGRA 32 bit mentah per piksel. Alpha tidak digunakan untuk OnNewFrame dan OnFramechanged kecuali untuk OnMouseChanged di mana itu digunakan!
Data ada seperti ini jika Anda berbaris dengan A untuk Loop [a, r, g, b], [a, r, g, b], [a, r, g, b]. Untuk dibaca mengapa ini memeriksa posting di sini di sini
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 ) ;Hanya tentukan apa yang Anda minati. Jangan tentukan panggilan balik untuk OnMouseChanged jika Anda tidak menginginkan informasi itu. Jika Anda melakukannya, perpustakaan akan berasumsi bahwa Anda ingin informasi mouse dan memantau itu -jadi jangan!
Sekali lagi, jangan tentukan panggilan balik untuk acara yang tidak Anda pedulikan. Jika Anda melakukannya, perpustakaan akan melakukan pekerjaan ekstra dengan asumsi Anda menginginkan informasinya.
Perpustakaan memiliki semua data gambar jadi jika Anda ingin menggunakannya untuk tujuan Anda sendiri setelah panggilan balik selesai, Anda harus menyalin data!
Setiap monitor atau jendela akan berjalan di utasnya sendiri sehingga tidak ada pemblokiran atau sinkronisasi internal. Jika Anda menangkap tiga monitor, sebuah utas menangkap setiap monitor.
Panggilan ke IcaptureConfiguration tidak dapat diubah setelah start_capturing dipanggil. Anda harus menghancurkannya dan membuatnya kembali!
Panggilan ke isCreencaptureManager dapat diubah kapan saja dari utas apa pun karena semua panggilan adalah utas aman!