无法将GDI内容绘制到Direct2D GdiInteropRenderTarget [英] Failed to draw GDI contents to a Direct2D GdiInteropRenderTarget

查看:184
本文介绍了无法将GDI内容绘制到Direct2D GdiInteropRenderTarget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将GDI内容绘制到Direct2D GdiInteropRenderTarget,我按照msdn网站上的说明进行操作:

I am trying to draw GDI contents to a Direct2D GdiInteropRenderTarget, I follow the instructions from msdn website:

https://msdn.microsoft.com/en-us / library / windows / desktop / dd370971(v = vs.85).aspx#draw_gdi_content_to_a_direct2d_gdi-compatible_render_target

https://msdn.microsoft.com/en-us/library/windows/desktop/dd370971(v=vs.85).aspx#draw_gdi_content_to_a_direct2d_gdi-compatible_render_target

以下是代码:

    m_pRenderTarget->BeginDraw();
    m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity());
    m_pRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White));

    // GDI content
    HDC hDC = NULL;
    HRESULT hr = m_pGDIRT->GetDC(D2D1_DC_INITIALIZE_MODE_COPY, &hDC);
    ::TextOut(hDC, 30, 30, _T("HelloWorld"), 10);
    m_pGDIRT->ReleaseDC(NULL);

    hr = m_pRenderTarget->EndDraw();

如果我首先清除rendertarget,我什么都找不到被拉到窗口。

If I clear the rendertarget at first, I find nothing is drawn to the window.

如果我最初没有清除rendertarget,可以正确地将GDI内容绘制到窗口,但背景是黑色的。

If I don't clear the rendertarget at first, the GDI contents can be drawn to the window correctly, but the background is black.

如果我首先清除rendertarget,然后绘制direct2d图形,最后绘制GDI图形,则direct2d内容正常,但GDI内容不完整,就像它被direct2d内容剪辑一样。

If I clear the rendertarget at first, then draw direct2d graphics, and draw GDI graphics last, the direct2d contents is OK, but the GDI contents is incomplete, just like it is clip by the direct2d contents.

我想知道如何正确绘制GDI内容,尤其是使用direct2d内容。

I want to know how to draw GDI contents correctly, especially with direct2d contents.

推荐答案

您可能想在GDI之前尝试EndDraw()

You might want to try the EndDraw() before the GDI


这篇关于无法将GDI内容绘制到Direct2D GdiInteropRenderTarget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆