locked
D2D Solid Brush With Alpha

    Question

  • DrawGeometry with solid brush with alpha color, when one stroke covers another, why some will add 2 alpha value, some will not?

    C++ DX11

    Wednesday, May 2, 2012 5:15 PM

Answers

  • Seems there will be several "DrawGlyphRun" calls in ONE "IDWriteTextLayout.Draw" command when using Asian fonts. (Is it a bug, or ?  ) A new DrawGlyphRun will cover the old one. So just do not draw in DrawGlyphRun .

    D2D and DWrite seems not fast enough, and I will only use it in offline rendering.


    • Marked as answer by Raptor K Thursday, May 10, 2012 4:45 PM
    • Edited by Raptor K Thursday, May 10, 2012 4:53 PM
    Thursday, May 10, 2012 4:45 PM

All replies

  • Hello,

    I draw a gird but can not reproduce this issue. Would you please provide us some codes to reproduce it?

    // In head file
    Microsoft::WRL::ComPtr<ID2D1PathGeometry> m_pathGeometry[6];
    
    //void geomerty::CreateWindowSizeDependentResources() function
    	for(int i=0;i<2;i++)
    	{
    	DX::ThrowIfFailed(
    		m_d2dFactory->CreatePathGeometry(&m_pathGeometry[i])
    		);
    	ID2D1GeometrySink *pSink=NULL;
    	DX::ThrowIfFailed(m_pathGeometry[i]->Open(&pSink));
    	pSink->BeginFigure(D2D1::Point2F(100+i*50,200),D2D1_FIGURE_BEGIN_HOLLOW);
    	pSink->AddLine(D2D1::Point2F(100+i*50,700));
    		pSink->EndFigure(D2D1_FIGURE_END_CLOSED);
    	pSink->Close();
    	}
    	for(int i=2;i<6;i++)
    	{
    	DX::ThrowIfFailed(
    		m_d2dFactory->CreatePathGeometry(&m_pathGeometry[i])
    		);
    	ID2D1GeometrySink *pSink=NULL;
    	DX::ThrowIfFailed(m_pathGeometry[i]->Open(&pSink));
    	pSink->BeginFigure(D2D1::Point2F(100,200+(i-2)*50),D2D1_FIGURE_BEGIN_HOLLOW);
    	pSink->AddLine(D2D1::Point2F(700,200+(i-2)*50));
    	pSink->EndFigure(D2D1_FIGURE_END_CLOSED);
    	pSink->Close();
    	}
    
    
    //void geomerty::Render() function
    	for(int i=0;i<5;i++)
    	{
    		m_d2dContext->DrawGeometry(m_pathGeometry[i].Get(),m_solidBrush.Get(),30.f);
    	}

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 3, 2012 8:47 AM
    Moderator
  • See the DWriteCustomTextRenderer sample.

    DWriteCustomTextRenderer.cpp :  Change to alpha brush

            m_d2dContext->CreateSolidColorBrush(
                D2D1::ColorF(D2D1::ColorF::GreenYellow,0.5),
                &m_blackBrush
                )

    CustomTextRenderer.cpp : Draw wide Outline

        D2DDeviceContext->DrawGeometry(
            transformedGeometry.Get(),
            outlineBrush.Get(),32
            );

    Just because different fonts?  They are in ONE Draw command. Where can I set alpha operation mode. I DON'T want them added up.

    Some Asian characters' outline with SAME font even cover each other when there are several Draws in the CustomTextRenderer::DrawGlyphRun

    Why they are different?  Seems some characters are not drawn at one time.


    C++ DX11


    • Edited by Raptor K Thursday, May 3, 2012 12:43 PM
    • Marked as answer by Raptor K Wednesday, May 9, 2012 8:35 AM
    • Unmarked as answer by Raptor K Thursday, May 10, 2012 4:45 PM
    Thursday, May 3, 2012 12:20 PM
  •  

    Hi,

     

    Sorry for delay replay, did you solve this problem? If so, would you please sharing the solution with us?

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 10, 2012 11:44 AM
    Moderator
  • Seems there will be several "DrawGlyphRun" calls in ONE "IDWriteTextLayout.Draw" command when using Asian fonts. (Is it a bug, or ?  ) A new DrawGlyphRun will cover the old one. So just do not draw in DrawGlyphRun .

    D2D and DWrite seems not fast enough, and I will only use it in offline rendering.


    • Marked as answer by Raptor K Thursday, May 10, 2012 4:45 PM
    • Edited by Raptor K Thursday, May 10, 2012 4:53 PM
    Thursday, May 10, 2012 4:45 PM
  • Hello,

     

    Would you please provide us the whole codes to reproduce this issue?

     

    You can upload your project to skydriver

    http://skydrive.live.com/

     

    Best regards,

    Jesse



    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Friday, May 11, 2012 1:34 AM
    Moderator