With Windows Presentation Foundation, if I have an HWND, how can I capture it's window as an image that I can manipulate and display?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You can:
CreateBitmap()
to create a hBitmapGetDC()
on the hWndBitBlt()
the contents to the hBitmapReleaseDC()
Imaging.CreateBitmapSourceFromHBitmap()
to create a managedBitmapSource
DeleteObject()
on the hBitmapBitmapSource
as desiredSteps 1-4 and 6 use the Win32 API (GDI to be precise), Steps 5 and 7 are done using WPF
While above answer is great, this would have saved a ton of time too:
Using section:
Code:
Notice that this takes screenshot of given area in the screen and not of window. It works for my purposes, you probably have to modify it for yours :)