画圆用System.Drawing中 [英] Drawing circles with System.Drawing

查看:185
本文介绍了画圆用System.Drawing中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的代码,绘制一个矩形(我试着去改造用MS Paint)

 案矩形:
如果(tempDraw!= NULL)
{
tempDraw =(位图)snapshot.Clone();
图形G = Graphics.FromImage(tempDraw);
笔myPen =新朋(前景色,线宽;);
g.DrawRectangle(myPen,X1,Y1,X2-X1,Y2-Y1);
myPen.Dispose();
e.Graphics.DrawImageUnscaled(tempDraw,0,0);
g.Dispose();
}



但如果我要画一个圆,会有什么改变?

  g.DrawRectangle(myPen,X1,Y1,X2-X1,Y2-Y1); 


解决方案

尝试的DrawEllipse~~V 方法来代替。


I have this code that draws a Rectangle ( Im trying to remake the MS Paint )

 case "Rectangle":
               if (tempDraw != null)
                {
                    tempDraw = (Bitmap)snapshot.Clone();
                    Graphics g = Graphics.FromImage(tempDraw);
                    Pen myPen = new Pen(foreColor, lineWidth);
                    g.DrawRectangle(myPen, x1, y1, x2-x1, y2-y1);
                    myPen.Dispose();
                    e.Graphics.DrawImageUnscaled(tempDraw, 0, 0);
                    g.Dispose();
                }

But what if I want to draw a circle, what will change?

g.DrawRectangle(myPen, x1, y1, x2-x1, y2-y1);

解决方案

Try the DrawEllipse method instead.

这篇关于画圆用System.Drawing中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆