图形和GraphicsPath问题 [英] Graphics and GraphicsPath Issue

查看:62
本文介绍了图形和GraphicsPath问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人

我想将 Graphics 数据转换为矢量格式.为此,我从基本形状开始.在这里,我尝试获取Graphics对象的路径.为此,绘制一个Ellipse并尝试获取路径数据.当在屏幕上绘制此数据时,它会显示矩形.请让我知道如何获取此点的角度或如何获取圆的角点.总之,我需要在Graphics上执行任何draw( Ignore Image)它应为MoveTo,LineTo或Arc(angle)格式.

我正在为此使用以下代码.

Dear ALL

I want to convert Graphics data in vector format.For that I have start from basic shape.Here i am trying To get path of Graphics object.For that draw one Ellipse and try to get path data.But when draw this data on screen it show the rectangle.Please let me know how to get angle of this pointor how to get angular point of my circle.In short i need whatever draw(Ignore Image) on Graphics it should be MoveTo,LineTo or Arc(angle) format.

I am using following code for that.

private void Form1_Paint(object sender, PaintEventArgs e)
{
    Pen pen=new Pen(Color.Black);             
    GraphicsPath path = new GraphicsPath();       
    path.AddEllipse(10, 10, 50, 50);
    e.Graphics.DrawPath(pen, path);
   
    int icount = path.PointCount;
    PointF[] p = new PointF[icount];
    GraphicsPath Newpath = new GraphicsPath();            
    for (int k = 0; k < icount; k++)
    {
        p[k] = path.PathPoints[k];
        p[k].X += 50;
        p[k].Y += 50;                            
    }
    e.Graphics.DrawLines(pen, p);               
}


请让我知道如何解决.
是否还有其他获取此信息的方法.

谢谢


Please let me know how to solve it.
Is it any other way to get this information.

Thanks

推荐答案



网上有成千上万个有关C#的示例图形 [ ^ ].
以下是绘制椭圆的示例:
Hi,

You have thousands examples on net about C# Graphics[^].
Here is the example how to draw ellipse:
private void Form1_Paint(object sender, PaintEventArgs e)
       {
            System.Drawing.Graphics graphicsObj;

            graphicsObj = this.CreateGraphics();

            Pen myPen = new Pen(System.Drawing.Color.Green, 5);
            Rectangle myRectangle = new Rectangle(20, 20, 250, 200);
            graphicsObj.DrawEllipse(myPen, myRectangle);
       }


以下是其中一些:
1. http://www.dotnettutorials.com/tutorials/graphics/winforms-drawing-cs. aspx [^ ]
2. http://www.techotopia.com/index.php/Drawing_Graphics_in_C_Sharp [ http://www.deitel.com/articles/csharp_tutorials/20051025/IntroTo2DGraphics.html [^ ]

只是谷歌按关键字,您需要的,我敢肯定会找到您所需要的...


Here are some of them:
1. http://www.dotnettutorials.com/tutorials/graphics/winforms-drawing-cs.aspx[^]
2. http://www.techotopia.com/index.php/Drawing_Graphics_in_C_Sharp[^]
3. http://www.deitel.com/articles/csharp_tutorials/20051025/IntroTo2DGraphics.html[^]

Just google by keyword you need and I''m sure will find what you need...


这篇关于图形和GraphicsPath问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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