Skip to content

Commit be93201

Browse files
committed
Updated windows implementatin
Res changes now implemented
1 parent 670714b commit be93201

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Example/Screen_Capture_Example.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int main()
5959

6060
Copy(*imagewrapper[Index(monitor)], img);
6161

62-
tje_encode_to_file(s.c_str(), Width(*imagewrapper[Index(monitor)]), Height(*imagewrapper[Index(monitor)]), 4, (const unsigned char*)images[Index(monitor)].get());
62+
//tje_encode_to_file(s.c_str(), Width(*imagewrapper[Index(monitor)]), Height(*imagewrapper[Index(monitor)]), 4, (const unsigned char*)images[Index(monitor)].get());
6363

6464
};
6565
auto mousefunc = [&](const SL::Screen_Capture::Image* img, int x, int y) {

include/ScreenCapture.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace SL {
7373
CaptureCallback CaptureDifMonitor;
7474
//min interval between mouse captures
7575
int Mouse_Capture_Interval;
76-
//the function to be called on each mouse interval
76+
//the function to be called on each mouse interval. If a the mouse image has changed, img will not be null, otherwise, the only change is new mouse coords
7777
MouseCallback CaptureMouse;
7878
};
7979
class ScreenCaptureManagerImpl;

src/windows/GDIFrameProcessor.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace SL {
1313
std::unique_ptr<char[]> OldImageBuffer, NewImageBuffer;
1414
size_t ImageBufferSize;
1515
bool FirstRun;
16+
std::string MonitorName;
1617
};
1718

1819

@@ -29,8 +30,8 @@ namespace SL {
2930
}
3031
DUPL_RETURN GDIFrameProcessor::Init(std::shared_ptr<Monitor_Thread_Data> data) {
3132
auto Ret = DUPL_RETURN_SUCCESS;
32-
auto name = Name(*data->SelectedMonitor);
33-
_GDIFrameProcessorImpl->MonitorDC.DC = CreateDCA(name.c_str(), NULL, NULL, NULL);
33+
_GDIFrameProcessorImpl->MonitorName = Name(*data->SelectedMonitor);
34+
_GDIFrameProcessorImpl->MonitorDC.DC = CreateDCA(_GDIFrameProcessorImpl->MonitorName.c_str(), NULL, NULL, NULL);
3435
_GDIFrameProcessorImpl->CaptureDC.DC = CreateCompatibleDC(_GDIFrameProcessorImpl->MonitorDC.DC);
3536
_GDIFrameProcessorImpl->CaptureBMP.Bitmap = CreateCompatibleBitmap(_GDIFrameProcessorImpl->MonitorDC.DC, Width(*data->SelectedMonitor), Height(*data->SelectedMonitor));
3637

@@ -58,13 +59,21 @@ namespace SL {
5859
ret.bottom = Height(*_GDIFrameProcessorImpl->Data->SelectedMonitor);
5960
ret.right = Width(*_GDIFrameProcessorImpl->Data->SelectedMonitor);
6061

62+
DEVMODEA devMode;
63+
devMode.dmSize = sizeof(devMode);
64+
if(EnumDisplaySettingsA(_GDIFrameProcessorImpl->MonitorName.c_str(), ENUM_CURRENT_SETTINGS, &devMode)==TRUE){
65+
if (devMode.dmPelsHeight != ret.bottom || devMode.dmPelsWidth != ret.right) {
66+
return DUPL_RETURN::DUPL_RETURN_ERROR_EXPECTED;
67+
}
68+
}
69+
6170
// Selecting an object into the specified DC
6271
auto originalBmp = SelectObject(_GDIFrameProcessorImpl->CaptureDC.DC, _GDIFrameProcessorImpl->CaptureBMP.Bitmap);
6372

6473
if (BitBlt(_GDIFrameProcessorImpl->CaptureDC.DC, 0, 0, ret.right, ret.bottom, _GDIFrameProcessorImpl->MonitorDC.DC, 0, 0, SRCCOPY | CAPTUREBLT) == FALSE) {
6574
//if the screen cannot be captured, return
6675
SelectObject(_GDIFrameProcessorImpl->CaptureDC.DC, originalBmp);
67-
Ret = DUPL_RETURN::DUPL_RETURN_ERROR_EXPECTED;//likely a permission issue
76+
return DUPL_RETURN::DUPL_RETURN_ERROR_EXPECTED;//likely a permission issue
6877
}
6978
else {
7079

0 commit comments

Comments
 (0)