11

我已经使用 C++ 为 Windows 桌面应用程序实现了 Direct2D 应用程序,我在其中显示了模拟期间的图形结果(带有点、线和椭圆)。只要模拟仍在运行,我就会保留一个缓冲区来存储模拟值,并且每个时间间隔我都会简单地绘制这些值。现在的情况是,我直接在Hwnd( ID2D1HwndRenderTarget)上画

pRenderTarget->BeginDraw() 

for(values of simulation results)
pRenderTarget->DrawLine(....)

pRenderTarget->EndDraw()

现在我想使用位图进行离屏渲染/绘图,因为我需要将位图作为图像存储在计算机上(相当于截取/捕获屏幕截图以存储模拟结果)。在这种情况下我应该如何进行(有/没有 Direct2D IWICBitmapFactory- 用于以后的屏幕捕获)?

  1. 创建ID2D1HwndRenderTarget pHwndRenderTarget- 使用pD2DFactory->CreateHwndRenderTarget()

  2. 创建ID2D1BitmapFactory pBitmapFactory- 使用pHwndRenderTarget->CreateCompatibleRenderTarget()

  3. 创建一个空位图ID2D1Bitmap ID2D1Bitmap pBmp- 使用pBitmapFactory->CreateBitmap()

  4. ?? 我应该在这个位图上画线吗?如果没有,我应该在哪里画线

  5. 最后,我应该在谁BeginDraw()和之间EndDraw()放置位图?

  6. 稍后,我会截取这张位图的屏幕截图。没有IWICBitmapFactory我能做到这一点吗?任何代码示例将不胜感激。

4

0 回答 0