I am using the managed Graphics.CopyFromScreen method to take a Bitmap screenshot of a region on the screen.
Everything is working using the CopyPixelOperation.SourceCopy enum as the flag to the CopyFromScreen method… but unfortunately I need to capture layered / transparent windows that are in the region I’m trying to capture… and with only the SourceCopy enum these do not get picked up in the resulting image. This can be solved using the CopyPixelOperation.CaptureBlt… but I can’t find a way to do this:
Graphics.CopyFromScreen(left, top, 0, 0, size, CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt); // note the binary OR operator
… as this results in a “Bitwise Or is not possible on type enum” style error from Resharper – upon which I researched the error discovering that bitwise operations on enums happens on the numeric representation of the enum values and you will end up with another one of the available enum values (opposed to two of them).
Is there a way to pass two enums to this function or a similar function? I have a preference in staying managed if possible.
MSDN Documentation
As per MSDN:
You can’t combine those flags, you probably want to use
CopyPixelOperation.CaptureBltalone anyway.