Skip to content

Commit cb777c9

Browse files
committed
updates
1 parent a76e649 commit cb777c9

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

src_cpp/windows/GDIFrameProcessor.cpp

+27-28
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace Screen_Capture {
4343
return Ret;
4444
}
4545
DUPL_RETURN GDIFrameProcessor::ProcessFrame(const Monitor &currentmonitorinfo)
46-
{
46+
{
4747
auto Ret = DUPL_RETURN_SUCCESS;
4848

4949
ImageRect ret;
@@ -59,27 +59,25 @@ namespace Screen_Capture {
5959
SelectObject(CaptureDC.DC, originalBmp);
6060
return DUPL_RETURN::DUPL_RETURN_ERROR_EXPECTED; // likely a permission issue
6161
}
62-
else {
6362

64-
BITMAPINFOHEADER bi;
65-
memset(&bi, 0, sizeof(bi));
63+
BITMAPINFOHEADER bi;
64+
memset(&bi, 0, sizeof(bi));
6665

67-
bi.biSize = sizeof(BITMAPINFOHEADER);
66+
bi.biSize = sizeof(BITMAPINFOHEADER);
6867

69-
bi.biWidth = ret.right;
70-
bi.biHeight = -ret.bottom;
71-
bi.biPlanes = 1;
72-
bi.biBitCount = sizeof(ImageBGRA) * 8; // always 32 bits damnit!!!
73-
bi.biCompression = BI_RGB;
74-
bi.biSizeImage = ((ret.right * bi.biBitCount + 31) / (sizeof(ImageBGRA) * 8)) * sizeof(ImageBGRA) * ret.bottom;
75-
GetDIBits(MonitorDC.DC, CaptureBMP.Bitmap, 0, (UINT)ret.bottom, NewImageBuffer.get(), (BITMAPINFO *)&bi, DIB_RGB_COLORS);
76-
SelectObject(CaptureDC.DC, originalBmp);
77-
ProcessCapture(Data->ScreenCaptureData, *this, currentmonitorinfo, NewImageBuffer.get(), Width(SelectedMonitor)* sizeof(ImageBGRA));
78-
}
68+
bi.biWidth = ret.right;
69+
bi.biHeight = -ret.bottom;
70+
bi.biPlanes = 1;
71+
bi.biBitCount = sizeof(ImageBGRA) * 8; // always 32 bits damnit!!!
72+
bi.biCompression = BI_RGB;
73+
bi.biSizeImage = ((ret.right * bi.biBitCount + 31) / (sizeof(ImageBGRA) * 8)) * sizeof(ImageBGRA) * ret.bottom;
74+
GetDIBits(MonitorDC.DC, CaptureBMP.Bitmap, 0, (UINT)ret.bottom, NewImageBuffer.get(), (BITMAPINFO *)&bi, DIB_RGB_COLORS);
75+
SelectObject(CaptureDC.DC, originalBmp);
76+
ProcessCapture(Data->ScreenCaptureData, *this, currentmonitorinfo, NewImageBuffer.get(), Width(SelectedMonitor) * sizeof(ImageBGRA));
7977

8078
return Ret;
8179
}
82-
80+
8381
DUPL_RETURN GDIFrameProcessor::ProcessFrame(Window &selectedwindow)
8482
{
8583
auto Ret = DUPL_RETURN_SUCCESS;
@@ -102,29 +100,30 @@ namespace Screen_Capture {
102100
auto left = -windowrect.ClientBorder.left;
103101
auto top = -windowrect.ClientBorder.top;
104102

105-
BOOL result = PrintWindow((HWND)selectedwindow.Handle, CaptureDC.DC, PW_RENDERFULLCONTENT );
103+
BOOL result = PrintWindow((HWND)selectedwindow.Handle, CaptureDC.DC, PW_RENDERFULLCONTENT);
106104

107-
if ( !result ) {
105+
if (!result) {
108106
result = BitBlt(CaptureDC.DC, left, top, ret.right, ret.bottom, MonitorDC.DC, 0, 0, SRCCOPY | CAPTUREBLT);
109107
}
110108

111-
if ( !result ) {
109+
if (!result) {
112110
// if the screen cannot be captured, return
113111
SelectObject(CaptureDC.DC, originalBmp);
114112
return DUPL_RETURN::DUPL_RETURN_ERROR_EXPECTED; // likely a permission issue
115113
}
116114

117-
//std::vector<HWND> childrenToComposite = CollectWindowsToComposite((HWND)selectedwindow.Handle);
115+
// std::vector<HWND> childrenToComposite = CollectWindowsToComposite((HWND)selectedwindow.Handle);
118116
//
119117
//// list is ordered topmost to bottommost, so we visit them in reverse order to let painter's algorithm work
120-
//for ( auto child = childrenToComposite.rbegin(); child != childrenToComposite.rend(); child++ ) {
121-
// auto childRect = SL::Screen_Capture::GetWindowRect( *child );
118+
// for ( auto child = childrenToComposite.rbegin(); child != childrenToComposite.rend(); child++ ) {
119+
// auto childRect = SL::Screen_Capture::GetWindowRect( *child );
122120

123121
// HDC srcDC = GetWindowDC(*child);
124122

125123
// // if this fails we just won't composite this window, so continue with the others to get what we can
126-
// BOOL childBlitSuccess = BitBlt(CaptureDC.DC, childRect.ClientRect.left - windowrect.ClientRect.left, childRect.ClientRect.top - windowrect.ClientRect.top,
127-
// childRect.ClientRect.right - childRect.ClientRect.left, childRect.ClientRect.bottom - childRect.ClientRect.top,
124+
// BOOL childBlitSuccess = BitBlt(CaptureDC.DC, childRect.ClientRect.left - windowrect.ClientRect.left, childRect.ClientRect.top -
125+
// windowrect.ClientRect.top,
126+
// childRect.ClientRect.right - childRect.ClientRect.left, childRect.ClientRect.bottom - childRect.ClientRect.top,
128127
// srcDC, 0, 0,
129128
// SRCCOPY | CAPTUREBLT);
130129
// if ( !childBlitSuccess ) {
@@ -135,17 +134,17 @@ namespace Screen_Capture {
135134
//}
136135

137136
BITMAPINFOHEADER bi;
138-
memset(&bi, 0, sizeof(bi));
139-
bi.biSize = sizeof(BITMAPINFOHEADER);
137+
memset(&bi, 0, sizeof(bi));
138+
bi.biSize = sizeof(BITMAPINFOHEADER);
140139
bi.biWidth = Width(ret);
141140
bi.biHeight = -Height(ret);
142141
bi.biPlanes = 1;
143142
bi.biBitCount = sizeof(ImageBGRA) * 8; // always 32 bits damnit!!!
144143
bi.biCompression = BI_RGB;
145-
bi.biSizeImage = ((Width(ret) * bi.biBitCount + 31) / (sizeof(ImageBGRA) * 8)) * sizeof(ImageBGRA) * Height(ret);
144+
bi.biSizeImage = ((Width(ret) * bi.biBitCount + 31) / (sizeof(ImageBGRA) * 8)) * sizeof(ImageBGRA) * Height(ret);
146145
GetDIBits(MonitorDC.DC, CaptureBMP.Bitmap, 0, (UINT)Height(ret), NewImageBuffer.get(), (BITMAPINFO *)&bi, DIB_RGB_COLORS);
147146
SelectObject(CaptureDC.DC, originalBmp);
148-
ProcessCapture(Data->WindowCaptureData, *this, selectedwindow, NewImageBuffer.get(), Width(selectedwindow)* sizeof(ImageBGRA));
147+
ProcessCapture(Data->WindowCaptureData, *this, selectedwindow, NewImageBuffer.get(), Width(selectedwindow) * sizeof(ImageBGRA));
149148

150149
return Ret;
151150
}

0 commit comments

Comments
 (0)