本文整理汇总了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;
}
示例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)
)
//.........这里部分代码省略.........