Skip to content

Commit 764c7ce

Browse files
committed
Updated windows build
1 parent 567b8e7 commit 764c7ce

File tree

2 files changed

+51
-25
lines changed

2 files changed

+51
-25
lines changed

Example/Screen_Capture_Example.cpp

+50-24
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,56 @@ int main()
2525

2626
auto framgrabber =
2727
SL::Screen_Capture::CreateScreeCapture([]() { return SL::Screen_Capture::GetMonitors(); })
28-
29-
.onNewFrame([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {
30-
31-
auto r = realcounter.fetch_add(1);
32-
auto s = std::to_string(r) + std::string(" E") + std::string(".jpg");
33-
34-
auto size = RowStride(img) * Height(img);
35-
//auto imgbuffer(std::make_unique<char[]>(size));
36-
// Extract(img, imgbuffer.get(), size);
37-
38-
//ExtractAndConvertToRGBA(img, imgbuffer.get(), size);
39-
40-
if(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() -
41-
onNewFramestart).count() >= 1000) {
42-
std::cout << "onNewFrame fps" << onNewFramecounter << std::endl;
43-
onNewFramecounter = 0;
44-
onNewFramestart = std::chrono::high_resolution_clock::now();
45-
}
46-
onNewFramecounter += 1;
47-
})
48-
49-
.start_capturing();
50-
51-
framgrabber.setFrameChangeInterval(std::chrono::milliseconds(0)); // 100 ms
28+
.onFrameChanged([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {
29+
std::cout << "height " << Height(img) << " width " << Width(img) << std::endl;
30+
auto r = realcounter.fetch_add(1);
31+
auto s = std::to_string(r) + std::string(" D") + std::string(".jpg");
32+
auto size = RowStride(img) * Height(img);
33+
34+
auto imgbuffer(std::make_unique<char[]>(size));
35+
// you can extract the image as is in BGRA, or Convert
36+
// Extract(img, imgbuffer.get(), size);
37+
ExtractAndConvertToRGBA(img, imgbuffer.get(), size);
38+
39+
// tje_encode_to_file(s.c_str(), Width(img), Height(img), 4, (const unsigned char*)imgbuffer.get());
40+
})
41+
.onNewFrame([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {
42+
43+
auto r = realcounter.fetch_add(1);
44+
auto s = std::to_string(r) + std::string(" E") + std::string(".jpg");
45+
46+
auto size = RowStride(img) * Height(img);
47+
auto imgbuffer(std::make_unique<char[]>(size));
48+
// Extract(img, imgbuffer.get(), size);
49+
50+
ExtractAndConvertToRGBA(img, imgbuffer.get(), size);
51+
52+
if (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() -
53+
onNewFramestart).count() >= 1000) {
54+
std::cout << "onNewFrame fps" << onNewFramecounter << std::endl;
55+
onNewFramecounter = 0;
56+
onNewFramestart = std::chrono::high_resolution_clock::now();
57+
}
58+
onNewFramecounter += 1;
59+
tje_encode_to_file(s.c_str(), Width(img), Height(img), 4, (const unsigned char*)imgbuffer.get());
60+
})
61+
.onMouseChanged([&](const SL::Screen_Capture::Image* img, int x, int y) {
62+
63+
auto r = realcounter.fetch_add(1);
64+
auto s = std::to_string(r) + std::string(" M") + std::string(".png");
65+
if (img) {
66+
// std::cout << "New Mouse Image x= " << x << " y= " << y << std::endl;
67+
// lodepng::encode(s, (const unsigned char*)StartSrc(*img), Width(*img), Height(*img));
68+
}
69+
else {
70+
// new coords
71+
// std::cout << "x= " << x << " y= " << y << std::endl;
72+
}
73+
74+
})
75+
.start_capturing();
76+
77+
framgrabber.setFrameChangeInterval(std::chrono::milliseconds(100)); // 100 ms
5278
framgrabber.setMouseChangeInterval(std::chrono::milliseconds(100)); // 100 ms
5379

5480
std::this_thread::sleep_for(std::chrono::seconds(10));

src/windows/DXFrameProcessor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ namespace SL {
406406
ret.left = ret.top = 0;
407407
ret.bottom = Height(SelectedMonitor);
408408
ret.right = Width(SelectedMonitor);
409-
auto startsrc = reinterpret_cast<char*>(MappingDesc.pData);
409+
auto startsrc = reinterpret_cast<unsigned char*>(MappingDesc.pData);
410410

411411
auto rowstride = PixelStride*Width(SelectedMonitor);
412412

0 commit comments

Comments
 (0)