예제 #1
0
        private void ShowGetDragDialog(out System.Drawing.Point[] line)
        {
            // スクリーン範囲ドラッグ
            var cs = new ScreenSelection();

            line = cs.ShowGetLineDialog(ImageCapture.BitmapFromScreen(), "ドラッグしてください");
        }
예제 #2
0
        /// <summary>
        /// 画像キャプチャとそこからのドラッグ位置を取得する
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="offset"></param>
        private void ShowGetDragOffsetFromCapture(out string filepath, out System.Drawing.Point[] line)
        {
            filepath = null;
            line     = null;

            var screen = ImageCapture.BitmapFromScreen();

            // スクリーン範囲ドラッグ
            var cs          = new ScreenSelection();
            var captureRect = cs.ShowGetRectDialog(screen, "画像領域をドラッグしてください");

            if (captureRect.IsEmpty)
            {
                return;
            }

            // 指定範囲をファイルに保存
            filepath = ShowSaveFileDialog();
            if (filepath == null)
            {
                return;
            }
            Bitmap bmp = screen.Clone(captureRect, screen.PixelFormat);

            bmp.Save(filepath, ImageFormat.Bmp);

            // 相対クリック一取得
            cs = new ScreenSelection();
            var absLine = cs.ShowGetLineDialog(screen, "ドラッグしてください");

            // 画像の切り出し
            line      = new System.Drawing.Point[2];
            line[0].X = absLine[0].X - captureRect.X;
            line[0].Y = absLine[0].Y - captureRect.Y;
            line[1].X = absLine[1].X - captureRect.X;
            line[1].Y = absLine[1].Y - captureRect.Y;
        }