BitBlt 截图问题

windhuan 2016-08-18 12:18:28
先上代码

IntPtr hdcSrc = IntPtr.Zero;
hdcSrc = User32.GetWindowDC(handle);
// create a device context we can copy to
IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
// create a bitmap we can copy it to,
// using GetDeviceCaps to get the width/height
IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, width, height);
// select the bitmap object
IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap);
// bitblt over
GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, x, y, GDI32.SRCCOPY);

// restore selection
GDI32.SelectObject(hdcDest, hOld);
// clean up
GDI32.DeleteDC(hdcDest);
User32.ReleaseDC(handle, hdcSrc);
// get a .NET image object for it
Image img = Image.FromHbitmap(hBitmap);
// free up the Bitmap object
GDI32.DeleteObject(hBitmap);
((Bitmap)img).Save("1.bmp");
return (Bitmap)img;



问题描述,此段代码是截取指定DirextX窗口图片,自从更新了Win10 周年更新后无法工作,截取出来是黑的,之前都是好好的
但是如果把handle设置为GetDesktopWindow() ,可以截图 包括DirextX窗口内容,如何修改才能截取指定DirextX窗口图片
...全文
389 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
秋的红果实 2016-08-20
  • 打赏
  • 举报
回复
win10的媒体编程接口版本是DirectX 12,也是最新版本,lz下载一个替换旧版本,应该可以解决问题
windhuan 2016-08-19
  • 打赏
  • 举报
回复
顶上去,不能沉
windhuan 2016-08-18
  • 打赏
  • 举报
回复
引用 4 楼 shingoscar 的回复:
handle怎么来的?
Process.MainWindowHandle
Poopaye 2016-08-18
  • 打赏
  • 举报
回复
handle怎么来的?
lshfong 2016-08-18
  • 打赏
  • 举报
回复
估计新版本的DX接口变动
windhuan 2016-08-18
  • 打赏
  • 举报
回复
XP-WIN10 都没有问题 只在Win10 周年更新后 version 1607 上出问题
a25179824 2016-08-18
  • 打赏
  • 举报
回复
WIN7表示没问题~
windhuan 2016-08-18
  • 打赏
  • 举报
回复
顶上去,不能沉

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧