当前位置: 首页>>代码示例>>C++>>正文


C++ ComPtr::SetColor方法代码示例

本文整理汇总了C++中microsoft::wrl::ComPtr::SetColor方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::SetColor方法的具体用法?C++ ComPtr::SetColor怎么用?C++ ComPtr::SetColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在microsoft::wrl::ComPtr的用法示例。


在下文中一共展示了ComPtr::SetColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawGlyphRun

IFACEMETHODIMP CustomTextRenderer::DrawGlyphRun(
    _In_opt_ void* clientDrawingContext,
    FLOAT baselineOriginX,
    FLOAT baselineOriginY,
    DWRITE_MEASURING_MODE measuringMode,
    _In_ DWRITE_GLYPH_RUN const* glyphRun,
    _In_ DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
    IUnknown* clientDrawingEffect
    )
{
    HRESULT hr = S_OK;
    HRESULT hrColor = DWRITE_E_NOCOLOR;
    DWRITE_MATRIX* worldToDeviceTransform = nullptr;

    Microsoft::WRL::ComPtr<IDWriteColorGlyphRunEnumerator> colorLayers;
    hrColor = m_dwriteFactory2->TranslateColorGlyphRun(
        baselineOriginX,
        baselineOriginY,
        glyphRun,
        nullptr,
        measuringMode,
        worldToDeviceTransform,
        0,
        &colorLayers
        );

    if (hrColor != DWRITE_E_NOCOLOR)
    {
        Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> solidBrush;

        for (;;){
        BOOL haveRun;
        DX::ThrowIfFailed(colorLayers->MoveNext(&haveRun));
        if (!haveRun)
            break;

            DWRITE_COLOR_GLYPH_RUN const* colorRun;
            DX::ThrowIfFailed(colorLayers->GetCurrentRun(&colorRun));

            ID2D1Brush* layerBrush;
            if (colorRun->paletteIndex == 0xFFFF)
            {
                layerBrush = m_outlineBrush.Get();
            }
            else
            {
                if (solidBrush == nullptr)
                {
                    DX::ThrowIfFailed(m_d2dDeviceContext->CreateSolidColorBrush(&colorRun->runColor, nullptr, &solidBrush));
                }
                else
                {
                    solidBrush->SetColor(colorRun->runColor);
                }
                layerBrush = solidBrush.Get();
            }

            m_d2dDeviceContext->DrawGlyphRun(
                D2D1::Point2(colorRun->baselineOriginX,colorRun->baselineOriginY),
                &colorRun->glyphRun,
                colorRun->glyphRunDescription,
                layerBrush,
                measuringMode
            );
        }
    }

    if (hrColor == DWRITE_E_NOCOLOR)
    {
        // Usual case: the run does not have any colored glyphs.
        m_d2dDeviceContext->DrawGlyphRun(
            D2D1::Point2(baselineOriginX,baselineOriginY), 
            glyphRun, 
            m_outlineBrush.Get(),
            measuringMode
            );
    }

    return hr;
}
开发者ID:mbin,项目名称:Win81App,代码行数:80,代码来源:CustomTextRenderer.cpp


注:本文中的microsoft::wrl::ComPtr::SetColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。