예제 #1
0
        private void btnDraw_Click(object sender, EventArgs e)
        {
            if (pbxPreview.Image == null)
            {
                MessageBox.Show("No image selected. Click 'Browse' to select an image.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Hide();
                Thread.Sleep(500);

                Bitmap image = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                using (Graphics g = Graphics.FromImage(image))
                {
                    g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, image.Size, CopyPixelOperation.SourceCopy);
                    g.DrawRectangle(Pens.Red, 1, 1, image.Width - 3, image.Height - 3);
                }

                ScreenOverlay overlay = new ScreenOverlay(image);
                Show();

                if (overlay.ShowDialog() == DialogResult.OK)
                {
                    WindowState = FormWindowState.Minimized;
                    image.Dispose();
                    Bitmap bmp = ResizeImage(pbxPreview.Image, overlay.Dim.Width, overlay.Dim.Height);
                    Thread.Sleep(1000);

                    _lastPoint = new Point(-1, -1);
                    _pid       = GetActiveProcess();

                    bmp = MakeGrayScale(bmp);

                    bmp = DitherImage(bmp);
                    pbxPreview.Image = bmp;
                    Draw(bmp, overlay.Pos.X, overlay.Pos.Y);
                    WindowState = FormWindowState.Normal;
                }
            }
        }
예제 #2
0
        private void btnDraw_Click(object sender, EventArgs e)
        {
            if (_original == null)
            {
                MessageBox.Show("No image selected. Click 'Browse' to select an image.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Hide();
                Thread.Sleep(500);

                Bitmap image = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                using (Graphics g = Graphics.FromImage(image))
                {
                    g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, image.Size, CopyPixelOperation.SourceCopy);
                    g.DrawRectangle(Pens.Red, 1, 1, image.Width - 3, image.Height - 3);
                }

                ScreenOverlay overlay = new ScreenOverlay(image);
                Show();

                if (overlay.ShowDialog() == DialogResult.OK)
                {
                    WindowState = FormWindowState.Minimized;
                    image.Dispose();

                    CvInvoke.Resize(_img, _img, new Size(_img.Cols, _img.Rows));
                    CvInvoke.BitwiseNot(_img, _img);

                    Thread.Sleep(2000);

                    _lastPoint = new Point(-1, -1);
                    _pid       = GetActiveProcess();

                    Draw(_img, overlay.Pos.X, overlay.Pos.Y);
                    WindowState = FormWindowState.Normal;
                }
            }
        }