Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            image = SnippingTool.Snip();
            txtMeanConf1.Clear();

            if (image != null)
            {
                imageCounter++;
                procitanTekst   = "";
                button2.Enabled = true;
                getTextToolStripMenuItem.Enabled = true;
                button3.Enabled = false;
                speakToolStripMenuItem.Enabled = false;
                button4.Enabled = false;
                cancelSpeakingToolStripMenuItem.Enabled = false;
                consoleTab1.Text = "Succes image load!" + Environment.NewLine + Environment.NewLine;
                Bitmap bitmap          = new Bitmap(image);
                Image  processedImage  = bitmap.DrawAsGrayscale();
                Bitmap processedBitmap = new Bitmap(processedImage);
                panel2.BackgroundImage = processedBitmap; // postavi sredjeni
                panel1.BackgroundImage = bitmap;          // postavi odabrani
                consoleTab1.DeselectAll();
            }
            else
            {
                consoleTab1.Text = "Failed to load image!" + Environment.NewLine + Environment.NewLine;
                button2.Enabled  = false;
                getTextToolStripMenuItem.Enabled = false;
                button3.Enabled = false;
                speakToolStripMenuItem.Enabled = false;
                button4.Enabled = false;
                cancelSpeakingToolStripMenuItem.Enabled = false;
            }
        }
Пример #2
0
        public static Image Snip()
        {
            var rc = Screen.PrimaryScreen.Bounds;

            using (Bitmap bmp = new Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb))
            {
                using (Graphics gr = Graphics.FromImage(bmp))
                    gr.CopyFromScreen(0, 0, 0, 0, bmp.Size);
                using (var snipper = new SnippingTool(bmp))
                {
                    if (snipper.ShowDialog() == DialogResult.OK)
                    {
                        return(snipper.Image);
                    }
                }
                return(null);
            }
        }