计划用Graphics作图,做一个颜色条,也就是一定宽度的矩形条,矩形条内填充有颜色,各颜色可设置。如何画?

解决方案 »

  1.   

    http://www.wewill.cn/n32235c67.aspxSystem.Drawing.Graphics.DrawRectangle()   方法
      

  2.   

    什么颜色条进度条还是说比如游戏血量的那种条还有你这是WINFORM还是WEB啊
      

  3.   


                Bitmap map = new Bitmap(100,100);//测试图片的大小
                Graphics graphics = Graphics.FromImage(map);
                graphics.Clear(Color.White); //设置背景色为白色
                
                SolidBrush brush = new SolidBrush(Color.Red);
                //Pen pen = new Pen(brush);
                //pen.Color = Color.Red;
                //pen.Width = 2; //指定画笔的粗细
                //graphics.DrawRectangle(pen,0,0,50,50); //画空心矩形框
                graphics.FillRectangle(brush,0,0,50,50);//画实心矩形框
                //输出下看看效果
                FileStream stream = File.Open("C:\\test.bmp",FileMode.OpenOrCreate);
                map.Save(stream,ImageFormat.Bmp);
                stream.Flush();//确保从磁盘缓存写到了磁盘
                stream.Close();
      

  4.   

    Graphics g = this.CreateGraphics();
    Rectangle rect = new Rectangle(10, 10, 50, 50);
    SolidBrush b1 = new SolidBrush(Color.White);//定义单色画刷   
    g.FillRectangle(b1, rect);//填充这个矩形
      

  5.   

    是WinForm的。
    正在实验楼上兄弟们的方法。。方法正确!用矩形逐步填充。