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


C# SharpDX.CopyPixels方法代码示例

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


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

示例1: CreateTexture2DFromBitmap

 /// <summary>
 /// Creates a <see cref="SharpDX.Direct3D11.Texture2D"/> from a WIC <see cref="SharpDX.WIC.BitmapSource"/>
 /// </summary>
 /// <param name="device">The Direct3D11 device</param>
 /// <param name="bitmapSource">The WIC bitmap source</param>
 /// <returns>A Texture2D</returns>
 public static SharpDX.Direct3D11.Texture2D CreateTexture2DFromBitmap(SharpDX.Direct3D11.Device device, SharpDX.WIC.BitmapSource bitmapSource)
 {
     // Allocate DataStream to receive the WIC image pixels
     int stride = bitmapSource.Size.Width * 4;
     using (var buffer = new SharpDX.DataStream(bitmapSource.Size.Height * stride, true, true))
     {
         // Copy the content of the WIC to the buffer
         bitmapSource.CopyPixels(stride, buffer);
         return new SharpDX.Direct3D11.Texture2D(device, new SharpDX.Direct3D11.Texture2DDescription()
         {
             Width = bitmapSource.Size.Width,
             Height = bitmapSource.Size.Height,
             ArraySize = 1,
             BindFlags = SharpDX.Direct3D11.BindFlags.ShaderResource,
             Usage = SharpDX.Direct3D11.ResourceUsage.Immutable,
             CpuAccessFlags = SharpDX.Direct3D11.CpuAccessFlags.None,
             Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm,
             MipLevels = 1,
             OptionFlags = SharpDX.Direct3D11.ResourceOptionFlags.None,
             SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
         }, new SharpDX.DataRectangle(buffer.DataPointer, stride));
     }
 }
开发者ID:yiyi99,项目名称:RemoteTerminal,代码行数:29,代码来源:TextureLoader.cs

示例2: CreateTexture2DFromBitmap

 public static Texture2D CreateTexture2DFromBitmap(Device device, SharpDX.WIC.BitmapSource bitmapSource, Texture2DDescription texDesc)
 {
     // Allocate DataStream to receive the WIC image pixels
     int stride = bitmapSource.Size.Width * 4;
     using(var buffer = new SharpDX.DataStream(bitmapSource.Size.Height * stride, true, true))
     {
         // Copy the content of the WIC to the buffer
         bitmapSource.CopyPixels(stride, buffer);
         return new Texture2D(device, texDesc, new SharpDX.DataRectangle(buffer.DataPointer, stride));
     }
 }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:11,代码来源:DXTexture.cs


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