quadrupleslap / scrap

📸 Screen capture made easy!
https://crates.io/crates/scrap
595 stars 66 forks source link

[Windows] Image distorted #10

Closed demilich1 closed 7 years ago

demilich1 commented 7 years ago

cargo run --example screenshot

produces a distorted image on my Windows 10 machine. There are no panics and the output is a valid .png, but somehow the pixels are not where they should be. Find an example attached to this issue:

screenshot

quadrupleslap commented 7 years ago

Thanks for the report!

  1. Any tips on how I can reproduce this error?
  2. Can you also show what the image was expected to look like?
demilich1 commented 7 years ago

Well, reproducing it is just a matter of running the screenshot example on Windows 10. I did not add or change any code, just ran these two commands: git clone https://github.com/quadrupleslap/scrap.git and then cargo run --example screenshot

This produces the screenshot.png in my first post. It is just a snapshot of my desktop, I attached the correct version down below:

screenshot_correct

quadrupleslap commented 7 years ago

🤔 Well, it works fine for me on Windows 10, so that doesn't narrow things down. Sorry for bothering you, but:

demilich1 commented 7 years ago

So it seems this is not a general WIndows 10 issue, but maybe somehow related to my specific configuration.

I may be able to test this on another Windows 10 machine this evening, I will let you know if there is the same issue or if it works

demilich1 commented 7 years ago

I was able to test this on another Windows 10 machine... everything worked fine. So this is somehow related to my hardware/software setup. I updated my graphics driver (running a GeForce 460 GTX) and still get distorted screenshots. So I don't know what the problem is, but if no other users are affected it may be an isolated problem.

quadrupleslap commented 7 years ago

Oh, the graphics card might be it! The library is dependent on Direct3D 11, which the card probably will, but might not, support. Not sure how that would result in this kind of glitching, though.

demilich1 commented 7 years ago

According to Wikipedia Direct3D 11 should be supported for the GTX 460. But maybe this is still somehow a problem. Do you see any way to maybe downgrade that dependency to Direct3D 9? I mean, even a 20 year old graphics should be able to take screenshots, right?

quadrupleslap commented 7 years ago

According to Microsoft, Desktop Duplication requires DXGI 1.2, i.e. Direct3D 11.1, but according to the Wikipedia article it only supports Direct3D 11.0. Adding backwards compatibility will most likely require doing something like what OBS Studio does as a fallback. The strangest thing is, why does it still produce a pretty similar image if it shouldn't support the API?

demilich1 commented 7 years ago

Yeah, that is a bit strange. Still, it is at least a semi-logical explanation for the behaviour ;) The other Windows machine I tested on had a GTX 1070 btw, so that would fit as well

quadrupleslap commented 7 years ago

Okay, I'm closing this because it seems to be resolved, but I also opened #11. Also, do you think that a fallback for DirectX 9.0-11.0 is worth implementing?

demilich1 commented 7 years ago

Well, of course I may be biased, but I do think it would be worth it. There are many computers with old hardware out there and at least I would expect screenshotting to work on basically any machine. Just my opinion though.

No matter if you decide to implement the fallback or not, I think this is a cool crate.. thank you for it!

mallochine commented 6 years ago

I'd like the fallback. By the way, for some reason I saw distorted pic with DirectX 12.0

quadrupleslap commented 6 years ago

Oh my god I'm an idiot - the stride was more than just the width! The problem's fixed now for the screenshot, but not for the ffplay example yet. I should also probably add a warning in the README.