Esempio n. 1
0
        public void initiateScreen()
        {
            int count   = 0;
            int s_count = 0;

            byte[]        buf  = new byte[4];
            Surface       s    = _sc.CaptureScreen();
            DataRectangle dr   = s.LockRectangle(LockFlags.None);
            DataStream    data = dr.Data;

            for (int y = 0; y < 768; y++)
            {
                for (int x = 0; x < 1024; x++)
                {
                    data.Position = count;
                    data.Read(buf, 0, 4);
                    _screen[s_count]     = buf[0]; //B
                    _screen[s_count + 1] = buf[1]; //G
                    _screen[s_count + 2] = buf[2]; //R
                    count   = count + 4;
                    s_count = s_count + 3;
                }
            }
            //saveBMP(dr.Data);
            s.UnlockRectangle();
            s.Dispose();
        }
        void Calculate()
        {
            Surface       s       = sc.CaptureScreen();
            DataRectangle dr      = s.LockRectangle(LockFlags.None);
            DataStream    gs      = dr.Data;
            List <Color>  theCols = new List <Color>();

            /* TODO::
             *
             * var topList = new Collection<long>(tlPos.Concat(tPos).Concat(trPos).ToList());
             * var leftList = new Collection<long>(tlPos.Concat(lPos).Concat(blPos).ToList());
             * var rightList = new Collection<long>(trPos.Concat(rPos).Concat(brPos).ToList());
             * List<Color> splittedLedsList = new List<Color>(splitToLeds(gs, leftList, 10).Concat(splitToLeds(gs, topList, 40)).Concat(splitToLeds(gs, rightList, 10)));*/
            //LEFT
            theCols.Add(avcs(gs, tlPos));
            theCols.Add(avcs(gs, lPos));
            theCols.Add(avcs(gs, blPos));//blPos //tPos)

            //TOP
            theCols.Add(avcs(gs, tPos));
            //BOTTOM
            theCols.Add(avcs(gs, bPos));

            //RIGHT
            theCols.Add(avcs(gs, trPos));
            theCols.Add(avcs(gs, rPos));
            theCols.Add(avcs(gs, brPos));


            //theCols.Reverse();

            List <Color> finalList = new List <Color>();

            foreach (Color col in theCols)
            {
                for (int i = 0; i < 7; i++)
                {
                    finalList.Add(col);
                }
            }
            finalList.Add(theCols[theCols.Count - 1]);
            finalList.Add(theCols[theCols.Count - 1]);
            finalList.Add(theCols[theCols.Count - 1]);


            write_color_stream(finalList);
            s.UnlockRectangle();
            s.Dispose();
            Thread.Sleep(Convert.ToInt32(textBox1.Text));
        }