Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //截取设置的区域屏幕图片
            Bitmap _screenShots = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
            // 创建一个画板,让我们可以在画板上画图
            // 这个画板也就是和屏幕大小一样大的图片
            // 我们可以通过Graphics这个类在这个空白图片上画图
            Graphics g_screenShots = Graphics.FromImage(_screenShots);

            // 把屏幕图片拷贝到我们创建的空白图片 CatchBmp中
            g_screenShots.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.AllScreens[0].Bounds.Width,
                                                                                    Screen.AllScreens[0].Bounds.Height));

            //剪切的图片
            _catchBmp_btn2 = new Bitmap(Tools.CatchRectangleSize.Width, Tools.CatchRectangleSize.Height);
            Graphics g = Graphics.FromImage(_catchBmp_btn2);

            g.DrawImage(_screenShots, new Rectangle(0, 0, Tools.CatchRectangleSize.Width, Tools.CatchRectangleSize.Height),
                        Tools.CatchRectangle, GraphicsUnit.Pixel);
            g.Dispose();
            g_screenShots.Dispose();

            pictureBox1.Width = Tools.CatchRectangleSize.Width;

            pictureBox1.Height = Tools.CatchRectangleSize.Height;

            //显示图像
            this.pictureBox1.BackgroundImage = (Image)_catchBmp_btn2;
            var result = BaiDuOCR.GeneralBasicDemo(_catchBmp_btn2);

            BindData(result);
        }
Ejemplo n.º 2
0
        internal void ReadImageResult()
        {
            //截取设置的区域屏幕图片
            Bitmap _screenShots = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
            // 创建一个画板,让我们可以在画板上画图
            // 这个画板也就是和屏幕大小一样大的图片
            // 我们可以通过Graphics这个类在这个空白图片上画图
            Graphics g_screenShots = Graphics.FromImage(_screenShots);

            // 把屏幕图片拷贝到我们创建的空白图片 CatchBmp中
            g_screenShots.CopyFromScreen(new Point(1, 1), new Point(0, 0), new Size(Screen.AllScreens[0].Bounds.Width,
                                                                                    Screen.AllScreens[0].Bounds.Height));

            //剪切的图片
            var      _catchBmp = new Bitmap(Tools.CatchRectangleSize.Width, Tools.CatchRectangleSize.Height);
            Graphics g         = Graphics.FromImage(_catchBmp);

            g.DrawImage(_screenShots, new Rectangle(1, 1, Tools.CatchRectangleSize.Width, Tools.CatchRectangleSize.Height),
                        Tools.CatchRectangle, GraphicsUnit.Pixel);
            g.Dispose();
            g_screenShots.Dispose();

            pictureBox1.Width = Tools.CatchRectangleSize.Width;

            pictureBox1.Height = Tools.CatchRectangleSize.Height;

            Image displayImage = (Image)_catchBmp;

            //显示图像
            this.pictureBox1.BackgroundImage = displayImage;

            var result = BaiDuOCR.GeneralBasicDemo(_catchBmp);

            BindData(result);
            //BaiDuOCR.AccurateBasicDemo(_catchBmp);
        }