Hello everyone, been a while since posting here...
I'm trying to write a full-screen magnification program in Visual basic .NET, which will likely utilize the Windows API (Pinvoke) to do it's magic.
The problem I am running into is that, when capturing the screen, you inevitably capture the window you display it on as well.
You get the 'infiniwindow' effect, where the captured image is captured and displayed again. It also results in strange glitches when you have a dynamic moving image.
I have tried several ways to capture the screen and displaying it WITHOUT ending up capturing my own drawn window. To do so, I need to draw 'above' the zero-DC buffer.
This is the method I used to draw to the screen (no topmost window as that gets inevitably captured too):
As you can see, getting the Graphics for handle IntPtr.ZERO results in the same graphics used to capture the screen. So, I end up capturing myself.
Draw is fired elsewhere using a timer.
Is there some way to capture the screen while EXCLUDING everything I rendered 'on top' of it? Can it be done with a fullscreen topmost window?
Alternatively, is it possible to be 'the man in the middle' transforming the graphics right before it is drawn to screen?
I'm trying to write a full-screen magnification program in Visual basic .NET, which will likely utilize the Windows API (Pinvoke) to do it's magic.
The problem I am running into is that, when capturing the screen, you inevitably capture the window you display it on as well.
You get the 'infiniwindow' effect, where the captured image is captured and displayed again. It also results in strange glitches when you have a dynamic moving image.
I have tried several ways to capture the screen and displaying it WITHOUT ending up capturing my own drawn window. To do so, I need to draw 'above' the zero-DC buffer.
This is the method I used to draw to the screen (no topmost window as that gets inevitably captured too):
PHP Code:
Public Class Magnifier
Dim screen As Screen
Dim bounds As Rectangle
Dim g As Graphics
Dim zoom As Double
Public Sub New(ByVal screen As Screen)
Me.screen = screen
Me.bounds = Me.screen.Bounds
Me.g = Graphics.FromHwnd(IntPtr.Zero)
End Sub
Public Sub Dispose()
g.Dispose()
End Sub
Public Sub SetZoom(ByVal zoom As Double)
Me.zoom = zoom
End Sub
Public Sub Draw()
g.CopyFromScreen(Cursor.Position, New Point(0, 0), New Size(400, 400))
End Sub
End Class
Draw is fired elsewhere using a timer.
Is there some way to capture the screen while EXCLUDING everything I rendered 'on top' of it? Can it be done with a fullscreen topmost window?
Alternatively, is it possible to be 'the man in the middle' transforming the graphics right before it is drawn to screen?