Example #1
0
        private void DrawTest_Load(object sender, EventArgs e)
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.UpdateStyles();

            //Bitmap bmp = new Bitmap(pbImg.Width, pbImg.Height);
            //Graphics g = Graphics.FromImage(bmp);
            //g.FillRectangle(new SolidBrush(pbImg.BackColor), new Rectangle(0, 0, pbImg.Width, pbImg.Height));
            //g.Dispose();

            Bitmap bmpformfile = new Bitmap(@"test.bmp");//获取打开的文件
            Bitmap bmp = new Bitmap(pbImg.Width, pbImg.Height);
            Graphics g = Graphics.FromImage(bmp);
            g.FillRectangle(new SolidBrush(pbImg.BackColor), new Rectangle(0, 0, pbImg.Width, pbImg.Height));//不使用这句话,那么这个bmp的背景就是透明的
            g.DrawImage(bmpformfile, 0, 0, bmpformfile.Width, bmpformfile.Height);//将图片画到画板上
            g.Dispose();//释放画板所占资源
            //不直接使用pbImg.Image = Image.FormFile(ofd.FileName)是因为这样会让图片一直处于打开状态,也就无法保存修改后的图片;详见http://www.wanxin.org/redirect.php?tid=3&goto=lastpost

            dt = new DrawTools(this.pbImg.CreateGraphics(), Color.Red, bmp);//实例化工具类
        }
Example #2
0
        private void DrawTest_Load(object sender, EventArgs e)
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.UpdateStyles();

            //Bitmap bmp = new Bitmap(pbImg.Width, pbImg.Height);
            //Graphics g = Graphics.FromImage(bmp);
            //g.FillRectangle(new SolidBrush(pbImg.BackColor), new Rectangle(0, 0, pbImg.Width, pbImg.Height));
            //g.Dispose();


            Bitmap   bmpformfile = new Bitmap(@"test.bmp");//获取打开的文件
            Bitmap   bmp         = new Bitmap(pbImg.Width, pbImg.Height);
            Graphics g           = Graphics.FromImage(bmp);

            g.FillRectangle(new SolidBrush(pbImg.BackColor), new Rectangle(0, 0, pbImg.Width, pbImg.Height)); //不使用这句话,那么这个bmp的背景就是透明的
            g.DrawImage(bmpformfile, 0, 0, bmpformfile.Width, bmpformfile.Height);                            //将图片画到画板上
            g.Dispose();                                                                                      //释放画板所占资源
            //不直接使用pbImg.Image = Image.FormFile(ofd.FileName)是因为这样会让图片一直处于打开状态,也就无法保存修改后的图片;详见http://www.wanxin.org/redirect.php?tid=3&goto=lastpost

            dt = new DrawTools(this.pbImg.CreateGraphics(), Color.Red, bmp);//实例化工具类
        }
Example #3
0
        private int glopara; //createMod 返回的指针int

        private void loadCapturePic(string picPath)
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.UpdateStyles();

            try
            {
                Bitmap   bmpformfile = new Bitmap(picPath != null ? picPath : @"test.bmp");//获取打开的文件
                Bitmap   bmp         = new Bitmap(picCapture.Width, picCapture.Height);
                Graphics g           = Graphics.FromImage(bmp);
                g.FillRectangle(new SolidBrush(picCapture.BackColor), new Rectangle(0, 0, picCapture.Width, picCapture.Height)); //不使用这句话,那么这个bmp的背景就是透明的
                g.DrawImage(bmpformfile, 0, 0, bmpformfile.Width, bmpformfile.Height);                                           //将图片画到画板上
                g.Dispose();                                                                                                     //释放画板所占资源
                //不直接使用pbImg.Image = Image.FormFile(ofd.FileName)是因为这样会让图片一直处于打开状态,也就无法保存修改后的图片;详见http://www.wanxin.org/redirect.php?tid=3&goto=lastpost

                dt = new DrawTools(this.picCapture.CreateGraphics(), Color.Red, bmp);//实例化工具类
            }
            catch (Exception e)
            {
                MessageBox.Show("暂未截图");
            }
        }
Example #4
0
        private void loadCapturePic(string picPath)
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.UpdateStyles();

            try
            {
                Bitmap bmpformfile = new Bitmap(picPath != null ? picPath : @"test.bmp");//获取打开的文件
                Bitmap bmp = new Bitmap(picCapture.Width, picCapture.Height);
                Graphics g = Graphics.FromImage(bmp);
                g.FillRectangle(new SolidBrush(picCapture.BackColor), new Rectangle(0, 0, picCapture.Width, picCapture.Height));//不使用这句话,那么这个bmp的背景就是透明的
                g.DrawImage(bmpformfile, 0, 0, bmpformfile.Width, bmpformfile.Height);//将图片画到画板上
                g.Dispose();//释放画板所占资源
                            //不直接使用pbImg.Image = Image.FormFile(ofd.FileName)是因为这样会让图片一直处于打开状态,也就无法保存修改后的图片;详见http://www.wanxin.org/redirect.php?tid=3&goto=lastpost

                dt = new DrawTools(this.picCapture.CreateGraphics(), Color.Red, bmp);//实例化工具类
            }
            catch (Exception e)
            {
                MessageBox.Show("暂未截图");
            }
        }