예제 #1
0
        void clientColorFrameReady(object sender, ColorFrameReadyEventArgs e)
        {
            if (sw.ElapsedMilliseconds >= 40)
            {
                if (!GameSpecs.PhotoTimerUp)
                {
                    try
                    {
                        placeholder = Texture2D.FromStream(g, e.ColorFrame.BitmapImage.StreamSource);
                    }
                    catch (Exception ex)
                    {
                        string error = ex.Message;
                    }
                }

                else
                {
                    BitmapImage photo = new BitmapImage();
                    if (GameSpecs.PhotoSwitch == false)
                    {
                        photo = e.ColorFrame.BitmapImage.Clone();
                        GameSpecs.TakenPhoto  = photo;
                        GameSpecs.PhotoSwitch = true;
                    }
                    else
                    {
                        photo = GameSpecs.TakenPhoto;
                    }

                    /// Catches the Frame and Converts it to memorystream
                    Stream       s  = photo.StreamSource;
                    MemoryStream ms = new MemoryStream();
                    s.Position = 0;
                    bool go = true;
                    while (go)
                    {
                        int  cur  = s.ReadByte();
                        byte conv = (byte)cur;

                        if (cur == -1)
                        {
                            go = false;
                        }
                        else
                        {
                            ms.WriteByte(conv);
                        }
                    }
                    ms.Position = 0;

                    Session.Picture = ms;
                    placeholder     = Texture2D.FromStream(g, s);
                    ms.Close();
                }
                sw.Restart();
            }
        }
 void colorClient_ColorFrameReady(object sender, ColorFrameReadyEventArgs e)
 {
     imageColor.Source = e.ColorFrame.BitmapImage;
 }