question

yoestar avatar image
0 Votes"
yoestar asked Viorel-1 commented

When using GDI to capture the window image and save it as BMP, the shadow around the window becomes black. Is there any way to solve it?

RT, Or is there a way to get the width of the shadow, the width of the red box in the attachment screenshot?
beforce capture:
128573-window-shandow1.jpg

after capture:
128574-window-shandow-gdi-capture.png



 capture desktop image:
 CreateCompatibleDC
 CreateCompatibleBitmap
 SelectObject
    
 capture window image:
 CreateCompatibleDC
 CreateCompatibleBitmap
 SelectObject
    
 compose window to desktop image:
 StretchBlt

windows-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
1 Vote"
Viorel-1 answered Viorel-1 commented

Try specifying ‘SRCCOPY | CAPTUREBLT’ in your BitBlt or StretchBlt calls.

If it does not help, then try calling DwmGetWindowAttribute(…, DWMWA_EXTENDED_FRAME_BOUNDS, …). It should return the rectangle without the black borders. Also use PhysicalToLogicalPointForPerMonitorDPI to convert the coordinates.

Check an example in C# that can be done in C++: https://docs.microsoft.com/en-us/answers/questions/522265/.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Try specifying ‘SRCCOPY | CAPTUREBLT’ in your BitBlt or StretchBlt calls.

yes, I use ‘SRCCOPY | CAPTUREBLT’ in your BitBlt or StretchBlt calls.


Is there an API that can get, including extended_ Function of rect of frame?
I want to calculate the scale of each window
Because our app is sometimes in system mode and sometimes in per monitor mode, we need to use DC width / rect to calculate the scale

0 Votes 0 ·

GetSystemMetrics+SM_CXSIZEFRAME, can obtain size of edge.

0 Votes 0 ·

But probably you cannot apply it to all of the edges and in any version of Windows or theme.

0 Votes 0 ·