Exemple #1
0
        public static void imgDecoder(object obj)
        {
            imgData imgdata = (imgData)obj;
            var     img     = new Image(imgdata.data);

            img.Decode();

            if (Frame.Width != img.Size.Width || Frame.Height != img.Size.Height)
            {
                Frame.Width = img.Size.Width;
            }
            Frame.Height = img.Size.Height;

            if (imgdata.ID == 1)
            {
                Frame.FrameBuffer1 = img.ToBuffer();
            }
            else
            {
                Frame.FrameBuffer2 = img.ToBuffer();
            }

            img.Dispose();
        }
Exemple #2
0
        private void ProcessPacket(Packet packet)
        {
            switch (packet.ID)
            {
            case 102:
                if (Frame.FrameReady)
                {
                    break;
                }

                try{
                    //AppMain.sceneMain.updateLabel((packet.Data.Length / 1024) + "kb");
                    //Console.WriteLine((packet.Data.Length / 1024) + "kb");
                    //var img = new Image(packet.Data);
                    //img.Decode();
                    //--boundary
                    int pos = packet.Data.Find(boundary);
                    if (pos != -1)
                    {
                        imgData img1 = new imgData();
                        imgData img2 = new imgData();
                        img1.ID   = 1;
                        img1.data = new byte[pos - 1];
                        Array.Copy(packet.Data, 0, img1.data, 0, img1.data.Length);

                        img2.ID   = 2;
                        img2.data = new byte[packet.Data.Length - (pos + boundary.Length)];
                        Array.Copy(packet.Data, pos + boundary.Length, img2.data, 0, img2.data.Length);

                        ThreadPool.QueueUserWorkItem(new WaitCallback(imgDecoder), img1);
                        ThreadPool.QueueUserWorkItem(new WaitCallback(imgDecoder), img2);
                    }
                    //Frame.FrameBuffer = img.ToBuffer(); //copy to image buffer
                    //img.Dispose();
                    //GC.Collect();
                }
                catch {
                }
                break;

            default:
                break;

            case 103:


                break;

            case 501:             // recieve if we are moving touch relative or not
            case 502:
            {
                Console.WriteLine(packet.ID + " recieved: " + (packet.Data.Length / 1024) + "kb");
                char[] fakeBool = new char[1];
                Array.Copy(packet.Data, 0, fakeBool, 0, 1);

                Console.WriteLine((int)fakeBool[0]);

                if (packet.ID == 501)
                {
                    Frame.RelativeDragOne = ((int)fakeBool[0] == 1);
                }
                else
                {
                    Frame.RelativeDragTwo = ((int)fakeBool[0] == 1);
                }
            } break;
            }
            #endregion
        }