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)?
create
ID2D1HwndRenderTarget pHwndRenderTarget
- usingpD2DFactory->CreateHwndRenderTarget()
create
ID2D1BitmapFactory pBitmapFactory
- usingpHwndRenderTarget->CreateCompatibleRenderTarget()
Create an empty bitmap
ID2D1Bitmap ID2D1Bitmap pBmp
- usingpBitmapFactory->CreateBitmap()
?? On this Bitmap should I draw lines? if not, where should I draw lines
In the end, between whose
BeginDraw()
andEndDraw()
, I should place the bitmap?Later at some point, I'd capture a screenshot of this bitmap. Without
IWICBitmapFactory
can I achieve this? Any code samples would be appreciated.