我想将ID2D1Effect的输出图像转换为ID2D1Bitmap,因此我可以在以后绘制它,而不必一遍又一遍地应用所有效果...
我的第一次尝试只是保留ID2D1Effect :: GetOutput图像ptr,但是如果我将效果与另一个图像源一起使用,则此图像会更改...
我的下一个尝试是创建一个设置了D2D1_BITMAP_OPTIONS_TARGET标志的位图(ID2D1DeviceContext :: CreateBitmap),并将效果输出绘制到该位图,但这似乎也不起作用...
绘制效果到给定的Bitmap1 **(目标):
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;
稍后绘制位图:(预览)
this->pD2DeviceContext->DrawBitmap(preview.Get(), D2D1::RectF(x, y, x+width, y + height));
(相同的DeviceContext-没有返回HRESULT的函数返回错误代码)
我究竟做错了什么?
我应该怎么做?
只是忘了在CreateBitmap中指定PixelFormat。
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED)
现在工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句