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


C# RenderTarget.CreateCompatibleRenderTarget方法代码示例

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


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

示例1: CreateGridPatternBrush

        /// <summary>
        /// Create the grid pattern (squares) brush 
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        BitmapBrush CreateGridPatternBrush(RenderTarget target)
        {

            // Create a compatible render target.
            BitmapRenderTarget compatibleRenderTarget =
                target.CreateCompatibleRenderTarget(CompatibleRenderTargetOptions.None, new SizeF(10.0f, 10.0f));

            //// Draw a pattern.
            SolidColorBrush spGridBrush = compatibleRenderTarget.CreateSolidColorBrush(new ColorF(0.93f, 0.94f, 0.96f, 1.0f));
            compatibleRenderTarget.BeginDraw();
            compatibleRenderTarget.FillRectangle(new RectF(0.0f, 0.0f, 10.0f, 1.0f), spGridBrush);
            compatibleRenderTarget.FillRectangle(new RectF(0.0f, 0.1f, 1.0f, 10.0f), spGridBrush);
            compatibleRenderTarget.EndDraw();

            //// Retrieve the bitmap from the render target.
            D2DBitmap spGridBitmap;
            spGridBitmap = compatibleRenderTarget.Bitmap;

            //// Choose the tiling mode for the bitmap brush.
            BitmapBrushProperties brushProperties = new BitmapBrushProperties(ExtendMode.Wrap, ExtendMode.Wrap, BitmapInterpolationMode.Linear);
            //// Create the bitmap brush.
            return renderTarget.CreateBitmapBrush(spGridBitmap, brushProperties);
        }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:28,代码来源:Window1.xaml.cs

示例2: CreateDeviceResources


//.........这里部分代码省略.........

            // Create a D2D render target which can draw into the surface in the swap chain
            RenderTargetProperties props =
                new RenderTargetProperties(
                    RenderTargetType.Default, new PixelFormat(Format.Unknown, AlphaMode.Premultiplied),
                    96, 96, RenderTargetUsage.None, FeatureLevel.Default);

            // Allocate a offscreen D3D surface for D2D to render our 2D content into
            Texture2DDescription tex2DDescription;
            tex2DDescription.ArraySize = 1;
            tex2DDescription.BindFlags = BindFlag.RenderTarget | BindFlag.ShaderResource;
            tex2DDescription.CpuAccessFlags = CpuAccessFlag.Unspecified;
            tex2DDescription.Format = Format.R8G8B8A8_UNORM;
            tex2DDescription.Height = 4096;
            tex2DDescription.Width = 512;
            tex2DDescription.MipLevels = 1;
            tex2DDescription.MiscFlags = 0;
            tex2DDescription.SampleDescription.Count = 1;
            tex2DDescription.SampleDescription.Quality = 0;
            tex2DDescription.Usage = Usage.Default;

            offscreenTexture = device.CreateTexture2D(tex2DDescription);

            using (Surface dxgiSurface = offscreenTexture.GetDXGISurface())
            {
                // Create a D2D render target which can draw into our offscreen D3D surface
                renderTarget = d2DFactory.CreateDxgiSurfaceRenderTarget(
                    dxgiSurface,
                    props);
            }

            PixelFormat alphaOnlyFormat = new PixelFormat(Format.A8_UNORM, AlphaMode.Premultiplied);

            opacityRenderTarget = renderTarget.CreateCompatibleRenderTarget(CompatibleRenderTargetOptions.None,
                                                                            alphaOnlyFormat);

            // Load pixel shader
            // Open precompiled vertex shader
            // This file was compiled using DirectX's SDK Shader compilation tool: 
            // fxc.exe /T fx_4_0 /Fo SciFiText.fxo SciFiText.fx
            shader = LoadResourceShader(device, "SciFiTextDemo.SciFiText.fxo");

            // Obtain the technique
            technique = shader.GetTechniqueByName("Render");

            // Obtain the variables
            worldMatrixVariable = shader.GetVariableByName("World").AsMatrix();
            viewMatrixVariable = shader.GetVariableByName("View").AsMatrix();
            projectionMarixVariable = shader.GetVariableByName("Projection").AsMatrix();
            diffuseVariable = shader.GetVariableByName("txDiffuse").AsShaderResource();

            // Create the input layout
            PassDescription passDesc = new PassDescription();
            passDesc = technique.GetPassByIndex(0).Description;

            vertexLayout = device.CreateInputLayout(
                inputLayoutDescriptions,
                passDesc.InputAssemblerInputSignature,
                passDesc.InputAssemblerInputSignatureSize
                );

            // Set the input layout
            device.IA.SetInputLayout(
                vertexLayout
                );
开发者ID:Prashant-Jonny,项目名称:phever,代码行数:66,代码来源:Window1.xaml.cs


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