示例#1
0
 private void ThreadFunction()
 {
     System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch();
     st.Start();
     while (shouldRun)
     {
         double t0 = st.Elapsed.TotalMilliseconds;
         //System.Console.WriteLine(1 / (t - time));
         Run();
         luna.Send();
         double t1        = st.Elapsed.TotalMilliseconds;
         double sleepTime = period - (t1 - t0);
         if (sleepTime > 0)
         {
             Thread.Sleep((int)Math.Round(sleepTime));
         }
     }
     Exit();
 }
示例#2
0
        private void PreviewControl1_OnScreenCaptured(Vector4[] pixels, int width, int height, int rowStride)
        {
            if (pixels == null)
            {
                luna.SendTurnOn();
                return;
            }

            Vector4[] pixelsLeft  = luna.pixelsLeft;
            Vector4[] pixelsRight = luna.pixelsRight;
            int       lunaDepth   = Settings.Default.LunaDepth;

            for (int i = 0; i < 120; i++)
            {
                int     num3   = rowStride * i;
                Vector4 vector = new Vector4();
                for (int j = 0; j < lunaDepth; j++)
                {
                    vector += (Vector4)((lunaDepth - j) * pixels[num3 + j]);
                }
                vector        = (Vector4)(vector * (2f / ((float)((1 + lunaDepth) * lunaDepth))));
                pixelsLeft[i] = Vector4.Transform(vector, colorCorrect);

                vector = new Vector4();
                num3  += width - 1;
                for (int k = 0; k < lunaDepth; k++)
                {
                    vector += (Vector4)((lunaDepth - k) * pixels[num3 - k]);
                }
                vector         = (Vector4)(vector * (2f / ((float)((1 + lunaDepth) * lunaDepth))));
                pixelsRight[i] = Vector4.Transform(vector, colorCorrect);
            }

            luna.whiteLeft  *= 0.97f;
            luna.whiteRight *= 0.97f;
            luna.Send();
        }