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


C# DataStream.ReadRange方法代码示例

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


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

示例1: GetBitmapData

        private unsafe byte* GetBitmapData(string s, out int stride)
        {

            FreeBitmapData();

            var size = GetMeasureString(s);

            var w = (int)(Math.Ceiling(size.Width += 2));
            var h = (int)(Math.Ceiling(size.Height += 2));

            CreateBitmap(w, h);

            _renderTarget.BeginDraw();

            _renderTarget.Clear(TransparentColor);
            _renderTarget.AntialiasMode = AntialiasMode.Aliased;
            textFormat.TextAlignment = TextAlignment.Center;
            _renderTarget.DrawText(s, textFormat, new RectangleF(0, 0, w, h), _brush);

            _renderTarget.EndDraw();

            //SaveToFile(@"C:\Xamarin\Cocos2D-XNAGraphics\" + s + ".png");

            // Calculate stride of source
            stride = _bitmap.Size.Width * 4;
            // Create data array to hold source pixel data
            //byte[] data = new byte[stride * _bitmap.Size.Height];
            byte[] data = new byte[stride * _bitmap.Size.Height];

            using (var datas = new DataStream(stride * _bitmap.Size.Height, true, true))
            {
                _bitmap.CopyPixels(stride, datas);

                data = datas.ReadRange<byte>(data.Length);
            }

            ReleaseResources();

            pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned);
            IntPtr pointer = pinnedArray.AddrOfPinnedObject();
            return (byte*)pointer; ;
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:42,代码来源:CCLabel-Windows.cs

示例2: Optimize

        /// <summary>	
        /// Generates a new mesh with reordered faces and vertices to optimize drawing performance.	
        /// </summary>	
        /// <remarks>	
        /// This method generates a new mesh. Before running Optimize, an application must generate an adjacency buffer by calling <see cref="SharpDX.Direct3D10.Mesh.GenerateAdjacencyAndPointRepresentation"/>. The adjacency buffer contains adjacency data, such as a list of edges and the faces that are adjacent to each other. This method is very similar to the <see cref="SharpDX.Direct3D10.Mesh.CloneMesh"/> method, except that it can perform optimization while generating the new clone of the mesh. The output mesh inherits all of the creation parameters of the input mesh. 	
        /// </remarks>	
        /// <param name="flags">Specifies the type of optimization to perform. This parameter can be set to a combination of one or more flags from D3DXMESHOPT and D3DXMESH (except D3DXMESH_32BIT, D3DXMESH_IB_WRITEONLY, and D3DXMESH_WRITEONLY). </param>
        /// <param name="faceRemap">An array of UINTs, one per face, that identifies the original mesh face that corresponds to each face in the optimized mesh.</param>
        /// <param name="vertexRemap">An array of index for each vertex that specifies how the new vertices map to the old vertices. This remap is useful if you need to alter external data based on the new vertex mapping. </param>
        /// <returns>The return value is one of the values listed in {{Direct3D 10 Return Codes}}. </returns>
        /// <unmanaged>HRESULT ID3DX10Mesh::Optimize([None] int Flags,[Out, Buffer, Optional] int* pFaceRemap,[In] LPD3D10BLOB* ppVertexRemap)</unmanaged>
        public void Optimize(MeshOptimizeFlags flags, out int[] faceRemap, out int[] vertexRemap)
        {

            IntPtr blobPtr;
            DataStream dataStream = null;
            unsafe
            {
                try
                {
                    faceRemap = new int[FaceCount];
                    Optimize((int)flags, faceRemap, new IntPtr(&blobPtr));
                    dataStream = new DataStream(new Blob(blobPtr));
                    vertexRemap = dataStream.ReadRange<int>(VertexCount);
                    dataStream.Dispose();
                }
                catch (Exception)
                {
                    faceRemap = null;
                    vertexRemap = null;
                    if (dataStream!=null)
                        dataStream.Dispose();
                    throw;
                }
            }
        }
开发者ID:Nezz,项目名称:SharpDX,代码行数:36,代码来源:Mesh.cs


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