我想要一个相对无黑客的方式来做这个,任何想法?例如,以下截图不包括半透明窗口:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
Text = "Opaque Window"
Dim win2 As New Form
win2.Opacity = 0.5
win2.Text = "Tranparent Window"
win2.Show()
win2.Top = Top + 50
win2.Left = Left() + 50
Dim bounds As Rectangle = System.Windows.Forms.Screen.GetBounds(Point.Empty)
Using bmp As Bitmap = New Bitmap(bounds.Width, bounds.Height)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size)
End Using
bmp.Save("c:\temp\scn.gif")
End Using
Process.Start(New Diagnostics.ProcessStartInfo("c:\temp\scn.gif") With {.UseShellExecute = True})
End Sub
End …Run Code Online (Sandbox Code Playgroud) 我知道如何使用GDI捕获屏幕,但它很慢(它几乎没有捕获10 fps)
我已经读过DirectX提供最佳速度.但在我开始学习DirectX之前,我想测试一个样本,看看它是否真的那么快.
我发现这个问题提供了一个示例代码来执行此操作:
void dump_buffer()
{
IDirect3DSurface9* pRenderTarget=NULL;
IDirect3DSurface9* pDestTarget=NULL;
const char file[] = "Pickture.bmp";
// sanity checks.
if (Device == NULL)
return;
// get the render target surface.
HRESULT hr = Device->GetRenderTarget(0, &pRenderTarget);
// get the current adapter display mode.
//hr = pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddisplaymode);
// create a destination surface.
hr = Device->CreateOffscreenPlainSurface(DisplayMde.Width,
DisplayMde.Height,
DisplayMde.Format,
D3DPOOL_SYSTEMMEM,
&pDestTarget,
NULL);
//copy the render target to the destination surface.
hr = Device->GetRenderTargetData(pRenderTarget, pDestTarget);
//save its contents to a bitmap file.
hr …Run Code Online (Sandbox Code Playgroud) 我想编写一个 Windows C++ 应用程序,其中窗口的内容是窗口后面的内容(就好像窗口是透明的一样)。也就是说,我想检索窗口的边界框;捕获下面的这些坐标,并将它们绘制在我的窗口上。因此,在捕获过程中排除窗口本身至关重要。
“为什么不让窗户透明呢?” 你问。因为我的下一步是对该图像进行修改。我想对其应用一些任意过滤器。例如,假设我想模糊该图像,使我的窗户看起来像毛玻璃。
我尝试使用https://code.msdn.microsoft.com/windowsdesktop/Magnification-API-Sample-14269fd2上的放大 API 示例 ,它实际上为我提供了不包括窗口的屏幕内容。然而,重新渲染图像是在计时器中完成的,这会导致图像非常抖动;我不知道如何检索该图像并将其应用任意变换。
我不知道从哪里开始,此时确实可以使用一些指针。抱歉,如果我是从一个愚蠢的角度来处理这个问题的。
编辑:我正在添加我的意思的模型:
编辑 2:就像放大 API 示例一样,视图将不断刷新(尽可能频繁地刷新,为了论证起见,假设每 16 毫秒刷新一次)。请参阅Visolve Deflector示例;尽管它不会对捕获区域施加任何效果。
再次强调,之后我将修改图像数据;因此我无法使用放大 API 的内核矩阵支持。