Пример #1
0
		void DepthClient_FrameReady(object sender, FrameReadyEventArgs e)
		{
			DepthFrameReadyEventArgs args = new DepthFrameReadyEventArgs();
			DepthFrameData dfd = new DepthFrameData();

			MemoryStream ms = new MemoryStream(e.Data);
			BinaryReader br = new BinaryReader(ms);

			dfd.PlayerIndexBitmask = br.ReadInt32();
			dfd.PlayerIndexBitmaskWidth = br.ReadInt32();

			DepthImageFrame frame = br.ReadDepthImageFrame();
			dfd.ImageFrame = frame;

			int dataLength = (int)(ms.Length - ms.Position);

			if(_depthShort == null || _depthShort.Length != dataLength / 2)
				_depthShort = new short[dataLength / 2];

			Buffer.BlockCopy(e.Data, (int)br.BaseStream.Position, _depthShort, 0, dataLength);

			dfd.DepthData = _depthShort;

			DepthFrame = dfd;
			args.DepthFrame = dfd;

			if(DepthFrameReady != null)
				DepthFrameReady(this, args);
		}
Пример #2
0
		void ColorClient_FrameReady(object sender, FrameReadyEventArgs e)
		{
			MemoryStream ms = new MemoryStream(e.Data);
			BinaryReader br = new BinaryReader(ms);

			ColorFrameReadyEventArgs args = new ColorFrameReadyEventArgs();
			ColorFrameData cfd = new ColorFrameData
			{
				Format = (ImageFormat)br.ReadInt32(),
				ImageFrame = br.ReadColorImageFrame()
			};

			if(cfd.Format == ImageFormat.Raw)
			    cfd.RawImage = br.ReadBytes(e.Data.Length - sizeof(bool));
			else
			{
				BitmapImage bi = new BitmapImage();
				bi.SetSource(new MemoryStream(e.Data, (int)ms.Position, (int)(ms.Length - ms.Position)));
				cfd.BitmapImage = bi;
			}

			ColorFrame = cfd;
			args.ColorFrame = cfd;

			if(ColorFrameReady != null)
				ColorFrameReady(this, args);
		}
Пример #3
0
		void AudioClient_FrameReady(object sender, FrameReadyEventArgs e)
		{
			AudioFrameReadyEventArgs args = new AudioFrameReadyEventArgs();
			AudioFrameData afd = new AudioFrameData();
			afd.AudioData = e.Data;

			args.AudioFrame = afd;
			AudioFrame = afd;

			if(AudioFrameReady != null)
				AudioFrameReady(this, args);
		}
Пример #4
0
		void SkeletonClient_FrameReady(object sender, FrameReadyEventArgs e)
		{
			MemoryStream ms = new MemoryStream(e.Data);
			BinaryReader br = new BinaryReader(ms);

			SkeletonFrameData frame = br.ReadSkeletonFrame();
			
			SkeletonFrameReadyEventArgs args = new SkeletonFrameReadyEventArgs { SkeletonFrame = frame };
			SkeletonFrame = frame;

			if(SkeletonFrameReady != null)
				SkeletonFrameReady(this, args);
		}