Exemplo n.º 1
0
        void RenderD2DContentIntoSurface()
        {
            SizeF rtSize = renderTarget.Size;

            renderTarget.BeginDraw();

            if (!isOpacityRTPopulated)
            {
                opacityRenderTarget.BeginDraw();

                opacityRenderTarget.Transform = Matrix3x2F.Identity;

                opacityRenderTarget.Clear(new ColorF(GetColorValues(System.Windows.Media.Colors.Black), 0));

                opacityRenderTarget.DrawText(
                    text,
                    textFormat,
                    new RectF(
                        0,
                        0,
                        rtSize.Width,
                        rtSize.Height
                        ),
                    textBrush
                    );

                opacityRenderTarget.EndDraw();

                isOpacityRTPopulated = true;
            }

            renderTarget.Clear(new ColorF(GetColorValues(System.Windows.Media.Colors.Black)));

            renderTarget.AntiAliasMode = AntiAliasMode.Aliased;

            D2DBitmap spBitmap = opacityRenderTarget.Bitmap;

            renderTarget.FillOpacityMask(
                spBitmap,
                textBrush,
                OpacityMaskContent.TextNatural,
                new RectF(0, 0, rtSize.Width, rtSize.Height),
                new RectF(0, 0, rtSize.Width, rtSize.Height)
                );

            renderTarget.EndDraw();
        }