smasherprog / screen_capture_lite

cross platform screen/window capturing library
MIT License
616 stars 156 forks source link

Strange border #150

Open Sean-Zeo opened 1 year ago

Sean-Zeo commented 1 year ago

Hi, when capturing a window frame on windows 10 there appears to be a small black border along the left and top of the image; image

smasherprog commented 1 year ago

Ill check this out later today and get back with you.

Sean-Zeo commented 1 year ago

Ill check this out later today and get back with you.

Hi friend, any update?

smasherprog commented 1 year ago

I cannot reproduce this problem. Can you try out the Example CPP project and run that code with these lines NOT commented out https://github.com/smasherprog/screen_capture_lite/blob/a76e6492761c01024334516e41d2594d62e2f0a5/Example_CPP/Screen_Capture_Example.cpp#L324

Then take a look at the output. See if you can reproduce it using the example code. You can comment out the other part of the test code, but run the code there and see if it still recurrs.

Sean-Zeo commented 1 year ago

Hi, here is the result; 0WINNEW_ image

The black border still occurs.

I've also noticed if there are certain characters in the window name, it causes this error; ArgumentException: Illegal byte sequence encounted in the input. I believe it's due to this character; image

-Sean

Sean-Zeo commented 1 year ago

Seems to be an offset of the buffer bytes of raw rgb?

Sean-Zeo commented 1 year ago

image Temporary fix of the "illegal byte sequence" error is to only allow letters, numbers, spaces & special characters.

smasherprog commented 1 year ago

this fixes the issue?

Sean-Zeo commented 1 year ago

this fixes the issue?

No, this only fixes the "illegal byte" crash when converting the w.Name to a string via; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] if it has special symbols.

This is unrelated to the border issue found when grabbing window frames.

Sean-Zeo commented 1 year ago

Hi, I noticed when using GetWindowRect(IntPtr hWnd, out RECT lpRect); the lpRect position is -8 x -8 when a window is maximized, could this be related?

smasherprog commented 1 year ago

Since i cant reproduce the problem i cant really help much unfortunately. :(

smasherprog commented 1 year ago

I can take a look at that illegal character issue. Looks like your visiting github issues page while capturing a window. I can check that out.

Sean-Zeo commented 1 year ago

Since i cant reproduce the problem i cant really help much unfortunately. :(

Hi why can't you reproduce? Do you not have access to a windows 10 machine? -Sean

smasherprog commented 1 year ago

I have windows 10 and windows 11 and it doesnt occur on either machines capturing a window. There is no black border around it :(

smasherprog commented 1 year ago

Its going to be something different on your machine than mine, so once that difference is identified we can fix it. Theres always little things that cause issues like this, but finding them is very hard. I have to rely on reporters to find the difference so it can be fixed in most cases.

Sean-Zeo commented 1 year ago

Hi, just testing on a virtual machine, vps && a different laptop, the issue still occurs? Can you show an example of it running correctly? The only window that seems to work without a border is task manager. Thanks!

smasherprog commented 1 year ago

You have put alot of effort into this and i appreciate it. I am heading into work not but when i get home from work ill get back at it and try some things out.

smasherprog commented 1 year ago

I did do some testing yesterday and found some issues with border calculations. I havent fixed it yet, but i did find an area of code that is not correct. Still working on it right now

smasherprog commented 1 year ago

This is super anooooying.. Its in https://github.com/smasherprog/screen_capture_lite/blob/cb777c9f84c47866612272c1486f21abfd4e5953/include/windows/GDIHelpers.h#L26

Ive been messing with it, but havent been able to fix it. TAG ur it!