private void button1_Click(object sender, EventArgs e)
        {
            Graphics gr =  CreateGraphics();
            Image bmp = new Bitmap(1024,800);
            Bitmap png = new Bitmap(@"D:\www.png");
            Pen pen = new Pen(Color.Black, 2);
            Brush br1 = new SolidBrush(Color.Red);
            gr = Graphics.FromImage(bmp);
            Brush br2 = new TextureBrush(png);
            Brush br3 = new LinearGradientBrush(new Point(100,0),new Point(300,0),Color.Red,Color.Blue);
            Brush br4 = new HatchBrush(HatchStyle.ForwardDiagonal,Color.Red,Color.White);
            
            gr.DrawEllipse(pen, 100, 100, 200, 200);//画圆轮廓
            gr.FillEllipse(br1, 100, 100, 200, 200);//纯色填充

            gr.DrawEllipse(pen, 300, 100, 200, 200);//画圆轮廓
            gr.FillEllipse(br2,300,100, 200, 200);//图片填充

            gr.DrawEllipse(pen, 500, 100, 200, 200);//画圆轮廓
            gr.FillEllipse(br3,500,100, 200, 200);//渐变填充

            gr.DrawEllipse(pen, 700, 100, 200, 200);//画圆轮廓
            gr.FillEllipse(br4, 700, 100, 200, 200);//网状填充
            pictureBox1.Image = bmp;//在PictureBox中显示结果
            //释放资源
            gr.Dispose();
            br1.Dispose();
            br2.Dispose();
            br3.Dispose();
            br4.Dispose();
            pen.Dispose();
        }

  运行结果:

pictureBox控件显示输出结果,遮挡或最小窗口不会影响显示效果

 

posted on 2022-06-05 20:30  sbwynnss  阅读(770)  评论(0)    收藏  举报