Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Store ID2D1Effect output in ID2D1Bitmap/Image to draw it at a later time?

$
0
0

Hey,

i want to convert the output image of an ID2D1Effect to an ID2D1Bitmap, so I'm able to draw it at a later time without applying all the effects over and over...

My first try was just to keep the ID2D1Effect::GetOutput image ptr, but this image changes if I use the effect with another image source...

My next try was to create a Bitmap (ID2D1DeviceContext::CreateBitmap) with D2D1_BITMAP_OPTIONS_TARGET flag set and draw the effects output to this Bitmap but that doesn't seem to work either...

Draw effect to given Bitmap1** (dest):

ComPtr<ID2D1Image> swapChainImageBuffer;
    this->pDeviceContext->CreateBitmap(D2D1::SizeU(120, 50), nullptr, 0, D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_TARGET), dest);
    this->pDeviceContext->GetTarget(swapChainImageBuffer.GetAddressOf());
    this->pDeviceContext->SetTarget(*dest);
    this->pDeviceContext->BeginDraw();
    this->pDeviceContext->Clear(D2D1::ColorF(RGB(0, 0, 0), 1.f));
    this->pDeviceContext->DrawImage(this->pCompositeEffect.Get(), D2D1::Point2F(20, 10));    
    this->pDeviceContext->EndDraw();
    this->pDeviceContext->SetTarget(swapChainImageBuffer.Get());
    swapChainImageBuffer = nullptr;

Draw the bitmap at a later time : (preview)

this->pD2DeviceContext->DrawBitmap(preview.Get(), D2D1::RectF(x, y, x+width, y + height));

(Same DeviceContext - no function that returns HRESULT returns an error code)

What am I doing wrong?

How am I supposed to do this?


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>