11

I already have implemented a Direct2D application for windows desktop application using C++, where I show the graphical results (with points, lines, and ellipses) during the simulation. I keep a buffer for storing the simulation values as long as the simulation remains running, and every time interval I simply plot the values. Right now, the situation is, I draw directly on Hwnd (ID2D1HwndRenderTarget) like

pRenderTarget->BeginDraw() 

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

pRenderTarget->EndDraw()

Now I want use the offscreen rendering/drawing using Bitmap, as I need to store the bitmap as an image on the computer (equivalent to taking/capturing screenshot to store the simulation results). How should I proceed in this case (with/without Direct2D IWICBitmapFactory - for later screen capturing)?

  1. create ID2D1HwndRenderTarget pHwndRenderTarget - using pD2DFactory->CreateHwndRenderTarget()

  2. create ID2D1BitmapFactory pBitmapFactory - using pHwndRenderTarget->CreateCompatibleRenderTarget()

  3. Create an empty bitmap ID2D1Bitmap ID2D1Bitmap pBmp - using pBitmapFactory->CreateBitmap()

  4. ?? On this Bitmap should I draw lines? if not, where should I draw lines

  5. In the end, between whose BeginDraw() and EndDraw(), I should place the bitmap?

  6. Later at some point, I'd capture a screenshot of this bitmap. Without IWICBitmapFactory can I achieve this? Any code samples would be appreciated.

m_drinks_coffee
  • 436
  • 8
  • 24

0 Answers0