private void videoBuilder_DoWork(object sender, DoWorkEventArgs e)
 {
     while (!videoBuilder.CancellationPending)
     {
         if (lastImage != null)
         {
             video.AddFrame(new BitmapVideoFrame(lastImage));
         }
         Thread.Sleep(frameDelayMs);
     }
 }
예제 #2
0
        public void CreateVideo()
        {
            const int width  = 640;
            const int height = 480;
            const int frames = 30;

            Stopwatch stopwatch  = Stopwatch.StartNew();
            var       parameters = new FlashScreenVideoParameters(width, height, 5)
            {
                BlockWidth  = 256,
                BlockHeight = 256
            };

            video = new FlashScreenVideo(parameters);
            stopwatch.Stop();

            Bitmap           bitmap           = new Bitmap(width, height);
            BitmapVideoFrame bitmapVideoFrame = new BitmapVideoFrame(bitmap);

            for (int frame = 0; frame < frames; frame++)
            {
                BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height),
                                                        ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                try
                {
                    int offset = 0;
                    for (int y = 0; y < height; y++)
                    {
                        int scanOffset = offset;

                        for (int x = 0; x < width; x++)
                        {
                            int color = (x * 255 / width) << 16 | (y * 255 / height) << 8 | frame * 255 / frames;
                            Marshal.WriteInt32(bitmapData.Scan0, scanOffset, color);

                            scanOffset += 4;
                        }

                        offset += bitmapData.Stride;
                    }
                }
                finally
                {
                    bitmap.UnlockBits(bitmapData);
                }

                stopwatch.Start();
                video.AddFrame(bitmapVideoFrame);
                stopwatch.Stop();
            }

            TestLog.WriteLine("Video encoding {2} frames at {0}x{1} took {3}s", width, height, frames, stopwatch.Elapsed.TotalSeconds);
        }
예제 #3
0
        void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!bgWorker.CancellationPending)
            {
                var bitmap = new Bitmap(WebDriverTestBase.testData.driver.GetScreenshot());
                Common.Log("Bitmap dimensions are : " + bitmap.Width + " x " + bitmap.Height);
                if (bitmap != null)
                {
                    video.AddFrame(new BitmapVideoFrame(bitmap));
                }

                Thread.Sleep(frameDelayMs);
            }
        }
예제 #4
0
 private void dispatcherTimer_Tick(object sender, EventArgs e)
 {
     Video.AddFrame(Screenshoter.TakeScreenshot(Screen.PrimaryScreen));
 }