2012-07-27 22 views
3

我可以創建使用下面的代碼IWICBitmap一個ID2D1RenderTarget ...如何爲IWICBitmap創建ID2D1DeviceContext? (對於C++ Metro應用)

D2D1_FACTORY_OPTIONS options; 
    ZeroMemory(&options, sizeof(D2D1_FACTORY_OPTIONS)); 

#if defined(_DEBUG) 
    // If the project is in a debug build, enable Direct2D debugging via SDK Layers 
    options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION; 
#endif 

    ThrowIfFailed(D2D1CreateFactory(
      D2D1_FACTORY_TYPE_SINGLE_THREADED, 
      __uuidof(ID2D1Factory1), 
      &options, 
      &m_d2dFactory 
      )); 

    D2D1_RENDER_TARGET_PROPERTIES props; 
    props = D2D1::RenderTargetProperties(); 
    m_d2dFactory->CreateWicBitmapRenderTarget(m_pTheBitmap.Get(), &props, &m_target); 

但是,如果我想ID2D1Effect適用於該位圖,我能做到這一點只有當我有ID2D1DeviceContext。如何獲得IWICBitmap的ID2D1DeviceContext?

回答

4

一旦您創建了渲染目標,您需要將QI指向ID2D1DeviceContext。例如

​​

請記住,QI也會增加參考計數。

+0

這對我有效!謝謝! – Litherum 2018-02-07 09:36:45

相關問題