Esempio n. 1
0
 public static System.Drawing.Bitmap GetBitmapFromScreen(IntPtr handle, BitmapPool pool, int width, int height)
 {
     System.Drawing.Bitmap bitmap;
     if(pool != null)
          bitmap = pool.GetInstance(width, height);
     else
         bitmap = new System.Drawing.Bitmap(width, height);
     Win32.GetThumbnailUsingCopyFromScreen(handle, bitmap);
     return bitmap;
 }
Esempio n. 2
0
        private void ThreadRun(object arg)
        {
            if (!_running)
            {
                _running = true;

                while (!_exitEvent.WaitOne(0, false))
                {
                    IntPtr windowHandle = (IntPtr)arg;
                    //Get the active window so we can translate it.
                    Tree window = _windowCapture.CaptureWindowWithPixels(windowHandle, UsePrintWindow, false);

                    if (window != null)
                    {
                        Prefab.Bitmap         capture = window["capturedpixels"] as Prefab.Bitmap;
                        System.Drawing.Bitmap bmp     = _pool.GetInstance(capture.Width, capture.Height);
                        Bitmap.ToSystemDrawingBitmap(capture, bmp);

                        // Get Window features
                        Win32.WINDOWINFO windowinfo = new Win32.WINDOWINFO(true);
                        Win32.GetWindowInfo(windowHandle, ref windowinfo);

                        // Save as png image
                        String filename = string.Format("{0}_f{1:D4}.png", _saveLoc.Substring(0, _saveLoc.Length - 4), frame_num);
                        bmp.Save(@filename, ImageFormat.Png);
                        frame_num++;


                        if (_videoStream == null)
                        {
                            _videoStream = _aviManager.AddVideoStream(false, 20, bmp);
                        }
                        else
                        {
                            _videoStream.AddFrame(bmp);
                        }

                        _pool.ReturnInstance(bmp);
                    }

                    //Let's not melt our processor ;)
                    Thread.Sleep(50);
                }
                _running = false;
                _aviManager.Close();
            }
        }
Esempio n. 3
0
 public static System.Drawing.Bitmap GetBitmapFromPrintWindow(IntPtr handle, BitmapPool pool, int width, int height)
 {
      System.Drawing.Bitmap bitmap;
      if (pool != null)
          bitmap = pool.GetInstance(width, height);
      else
          bitmap = new System.Drawing.Bitmap(width, height);
     Win32.GetThumbnailUsingPrintWindow(handle, bitmap);
     return bitmap;
 }