smasherprog / screen_capture_lite

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

Invalid mouse image on windows #84

Closed 0xd34d10cc closed 3 years ago

0xd34d10cc commented 4 years ago

Looks like the problem in this line: https://github.com/smasherprog/screen_capture_lite/blob/964494851bcc6234d8c00fe40b52e608d41d8ce6/src/windows/GDIMouseProcessor.cpp#L70

It sets BytesToNextRow to 0 and never updates it. This field is then used in GoToNextRow(): https://github.com/smasherprog/screen_capture_lite/blob/93c92d97f1ee4e4ec5df1364f5dd6955fcff2036/src/SCCommon.cpp#L245-L246 so Extract() function always copies the first line of image: https://github.com/smasherprog/screen_capture_lite/blob/93c92d97f1ee4e4ec5df1364f5dd6955fcff2036/include/ScreenCapture.h#L105-L107

smasherprog commented 4 years ago

is it possible for you to create a pull request on this by chance? Good find!

smasherprog commented 4 years ago

I think the function is probably not the clearest. The function GotoNextRow takes the END of the current row and just adds rowpadding on the pointer. So its not really named the best. If you look at the extract function, you can see the code moves the pointer along so it shouldnt get stuck on the first row

0xd34d10cc commented 4 years ago

I don't see where startsrc is advanced forward in Extract function besides this line: https://github.com/smasherprog/screen_capture_lite/blob/964494851bcc6234d8c00fe40b52e608d41d8ce6/include/ScreenCapture.h#L111

Also, here: https://github.com/smasherprog/screen_capture_lite/blob/93c92d97f1ee4e4ec5df1364f5dd6955fcff2036/include/internal/SCCommon.h#L88 BytesToNextRow is set to row stride, not padding, so something is definitely not right either in mouse capture code or in frame capture code.

smasherprog commented 4 years ago

Its definitely not consistent and I need to take a look at it. I wont get to it until this weekend sometime -- feel free to beat me to it with a PR! :)

smasherprog commented 3 years ago

Thanks for pointing this out. Its now fixed