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


C# Int16.SelectMany方法代码示例

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


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

示例1: Convert

        Bitmap Convert(V2DepthFrame frame)
        {
            if (m_bitmap == null)
            {
                m_bitmap = new Bitmap(frame.Width, frame.Height, PixelFormat.Format32bppRgb);
            }
            var data = m_bitmap.LockBits(new Rectangle(0, 0, m_bitmap.Width, m_bitmap.Height)
                , System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

            var buffer=new Int16[frame.BufferSize];
            Marshal.Copy(frame.Buffer, buffer, 0, buffer.Length);

            Marshal.Copy(buffer.SelectMany(d =>{
                    var dd=(Byte)((int)(d));
                    return new Byte[] { dd, dd, dd, dd }; 
                }).ToArray()
                , 0, data.Scan0, (Int32)(buffer.Length * 4));

            m_bitmap.UnlockBits(data);
            return m_bitmap;
        }
开发者ID:ousttrue,项目名称:UniKinect,代码行数:21,代码来源:Form1.cs

示例2: StartDepthHandler

        void StartDepthHandler(Int32 apiVersion, KinectImageResolution resolution)
        {
            var bitmap = new Bitmap(resolution.Width(), resolution.Height());
            var buffer = new Int16[resolution.Width() * resolution.Height()];


            if (apiVersion == 1)
            {
                Action<KinectBaseImageFrame> UpdatePictureBox = frame =>
                {
                    Marshal.Copy(frame.Ptr, buffer, 0, buffer.Length);
                    bitmap.SetPixels(buffer.SelectMany(d =>
                    {
                        var depth = ((Int32)d) >> 3;
                        if (depth > _tmpMaxDepth)
                        {
                            _tmpMaxDepth = depth;
                        }

                        var player= ((Int32)d) & 0x7;
                        var color = ColorMap[player];

                        return new Byte[]{
                        (Byte)(color.R * depth / MaxDepth)
                        , (Byte)(color.G * depth / MaxDepth)
                        , (Byte)(color.B * depth / MaxDepth)
                        , 255
                    };
                    }).ToArray());

                    pictureBoxForDepth.Image = bitmap;
                    if (_tmpMaxDepth > MaxDepth)
                    {
                        MaxDepth = _tmpMaxDepth;
                    }
                };
                _depthHandler = _timerEvent
                    .Where(_ => _sensor.DepthImageStream != null)
                    .Subscribe(_ => Observable.Using(
                        () => _sensor.DepthImageStream.GetFrame()
                        , frame => Observable.Return(frame)
                        )
                        .Where(frame => frame != null)
                        .Subscribe(
                            frame => UpdatePictureBox(frame)
                            , ex => {} // Console.WriteLine("error")
                        )
                    )
                    ;
            }
            else if(apiVersion==2)
            {
                Action<IEnumerable<Int16>, Byte[]> UpdatePictureBox = (db, ib) =>
                {
                    bitmap.SetPixels(db.Zip(ib.Select(index => (SByte)index), (depth, player) =>
                    {
                        if (depth > _tmpMaxDepth)
                        {
                            _tmpMaxDepth = depth;
                        }

                        var color = ColorMap[player+1];

                        return new Byte[]{
                        (Byte)(color.R * depth / MaxDepth)
                        , (Byte)(color.G * depth / MaxDepth)
                        , (Byte)(color.B * depth / MaxDepth)
                        , 255
                        };
                    }).SelectMany(pixel => pixel).ToArray());
                    pictureBoxForDepth.Image = bitmap;
                    if (_tmpMaxDepth > MaxDepth)
                    {
                        MaxDepth = _tmpMaxDepth;
                    }
                };

                var depthImage = _timerEvent
                    .Where(_ => _sensor.DepthImageStream != null)
                    .SelectMany(_ => Observable.Using(
                        ()=>_sensor.DepthImageStream.GetFrame()
                        , frame=>Observable.Return(frame)
                     )
                     .Catch((COMException ex)=>Observable.Return((KinectBaseImageFrame)null))
                     .Where(frame=>frame!=null)
                     .Select(frame =>
                     {
                         Marshal.Copy(frame.Ptr, buffer, 0, buffer.Length);
                         return new { Buffer = buffer, Time = frame.Time };
                     }
                     ))
                    ;

                var indexBuffer=new Byte[resolution.Width()*resolution.Height()];
                var indexImage = _timerEvent
                    .Where(_ => _sensor.IndexImageStream != null)
                    .SelectMany(_ => Observable.Using(
                        () => _sensor.IndexImageStream.GetFrame()
                            , frame => Observable.Return(frame)
                                )
//.........这里部分代码省略.........
开发者ID:ousttrue,项目名称:UniKinect,代码行数:101,代码来源:SensorControl.cs


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