コード例 #1
0
ファイル: ScreenCapture.cs プロジェクト: allen8673/AppRTC
        /// <summary>
        /// Reset Handling Windows Pointer
        /// </summary>
        /// <param name="hWnd">current Handling Windows Pointer</param>
        public void ResetHandlingPointer(IntPtr hWnd)
        {
            HandlingPtr = hWnd;

            // If hWnd is not Zero, just set HandlingPtr
            if (hWnd != IntPtr.Zero)
            {
                return;
            }

            // If hWnd is Zero, just consider as Full Screen Capture
            Rectangle windRtg = CaptureHelper.GetWindowCoordinate(hWnd);

            ContentSetting(this, windRtg.Width, windRtg.Height);
        }
コード例 #2
0
ファイル: ScreenCapture.cs プロジェクト: allen8673/AppRTC
        /// <summary>
        /// Create Screen Capture
        /// </summary>
        /// <param name="hWnd">Handling Windows Pointer</param>
        /// <returns></returns>
        public static ScreenCapture Create(IntPtr hWnd)
        {
            ScreenCapture sc = new ScreenCapture
            {
                HandlingPtr = hWnd,
            };

            // If hWnd is not Zero, just set HandlingPtr
            if (hWnd != IntPtr.Zero)
            {
                return(sc);
            }

            // If hWnd is Zero, just consider as Full Screen Capture
            Rectangle windRtg = CaptureHelper.GetWindowCoordinate(hWnd);

            ContentSetting(sc, windRtg.Width, windRtg.Height);
            return(sc);
        }
コード例 #3
0
        /// <summary>
        /// キャプチャ(ウィンドウ)
        /// </summary>
        /// <param name="el"></param>
        /// <param name="path"></param>
        void Cpt(System.Windows.Automation.AutomationElement el, string path)
        {
            if (el == null)
            {
                return;
            }

            if (el.Current.NativeWindowHandle != 0)
            {
                System.Drawing.Bitmap bmp = CaptureHelper.CaptureWindow((IntPtr)el.Current.NativeWindowHandle);
                bmp.Save(path, System.Drawing.Imaging.ImageFormat.Png);
            }

            /*
             * string name = el.Current.ControlType.LocalizedControlType;
             * string type = el.Current.ItemType;
             * string hnd = el.Current.NativeWindowHandle.ToString();
             * string pid = el.Current.ProcessId.ToString();
             */
        }
コード例 #4
0
        /// <summary>
        /// キャプチャ(切り抜き)
        /// </summary>
        /// <param name="p"></param>
        /// <param name="path"></param>
        void Cpt(Point p, string path_c, string path_w, CaptureEntry entry)
        {
            int top    = setting.ClipSizeTop;
            int left   = setting.ClipSizeLeft;
            int right  = setting.ClipSizeRight;
            int bottom = setting.ClipSizeBottom;

            System.Drawing.Bitmap bmp = CaptureHelper.CaptureScreen();

            int top_offset  = 0;
            int left_offset = 0;

            if ((p.Y + top) < 0)
            {
                top_offset = -((int)(p.Y + top));
            }
            else if (bmp.Height < (p.Y + bottom))
            {
                top_offset = bmp.Height - (int)(p.Y + bottom);
            }

            if ((p.X + left) < 0)
            {
                left_offset = -((int)(p.X + left));
            }
            else if (bmp.Width < (p.X + right))
            {
                left_offset = bmp.Width - (int)(p.X + right);
            }

            int adj_top    = top + top_offset;
            int adj_left   = left + left_offset;
            int adj_right  = right + left_offset;
            int adj_bottom = bottom + top_offset;

            //マウス範囲を切り抜く
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)(p.X + adj_left), (int)(p.Y + adj_top), -adj_left + adj_right, -adj_top + adj_bottom);
            entry.ClipImageRect = new Rect((int)(p.X + adj_left), (int)(p.Y + adj_top), -adj_left + adj_right, -adj_top + adj_bottom);
            System.Drawing.Bitmap bmpNew = bmp.Clone(rect, bmp.PixelFormat);
            bmpNew.Save(path_c, System.Drawing.Imaging.ImageFormat.Png);

            /*
             * this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
             * {
             *  MessageBox.Show(entry.WindowRect.X.ToString() + " " +
             *      entry.WindowRect.Y.ToString() + " " +
             *      entry.WindowRect.Width.ToString() + " " +
             *      entry.WindowRect.Height.ToString() + " ");
             * }));
             */

            //ウィンドウを範囲を切り抜く
            if (!entry.WindowRect.IsEmpty)
            {
                //領域座標を微調整する
                int w_x      = (int)entry.WindowRect.X;
                int w_y      = (int)entry.WindowRect.Y;
                int w_width  = (int)entry.WindowRect.Width;
                int w_height = (int)entry.WindowRect.Height;
                if (w_x < 0)
                {
                    w_x = 0;
                }
                if (w_y < 0)
                {
                    w_y = 0;
                }

                if (bmp.Width < (w_x + w_width))
                {
                    w_width = bmp.Width - w_x;
                }

                if (bmp.Height < (w_y + w_height))
                {
                    w_height = bmp.Height - w_y;
                }

                System.Drawing.Rectangle rect2   = new System.Drawing.Rectangle(w_x, w_y, w_width, w_height);
                System.Drawing.Bitmap    bmpNew2 = bmp.Clone(rect2, bmp.PixelFormat);
                bmpNew2.Save(path_w, System.Drawing.Imaging.ImageFormat.Png);
            }
        }